2019-03-29 14:54:34 +00:00
|
|
|
#ifndef CORE_ACCOUNT_H
|
|
|
|
#define CORE_ACCOUNT_H
|
|
|
|
|
|
|
|
#include <QtCore/QObject>
|
2019-04-03 21:23:51 +00:00
|
|
|
#include <map>
|
2019-04-06 10:14:32 +00:00
|
|
|
#include <set>
|
2019-03-29 14:54:34 +00:00
|
|
|
|
2019-04-12 15:22:10 +00:00
|
|
|
#include <qxmpp/QXmppRosterManager.h>
|
|
|
|
#include <qxmpp/QXmppCarbonManager.h>
|
2019-04-13 20:38:20 +00:00
|
|
|
#include <qxmpp/QXmppMamManager.h>
|
2019-03-29 14:54:34 +00:00
|
|
|
#include <qxmpp/QXmppClient.h>
|
2019-03-31 21:05:09 +00:00
|
|
|
#include "../global.h"
|
2019-04-17 20:08:56 +00:00
|
|
|
#include "contact.h"
|
2019-03-29 14:54:34 +00:00
|
|
|
|
|
|
|
namespace Core
|
|
|
|
{
|
|
|
|
|
|
|
|
class Account : public QObject
|
|
|
|
{
|
2019-03-31 21:05:09 +00:00
|
|
|
Q_OBJECT
|
2019-03-29 14:54:34 +00:00
|
|
|
public:
|
2019-03-30 20:13:13 +00:00
|
|
|
Account(const QString& p_login, const QString& p_server, const QString& p_password, const QString& p_name, QObject* parent = 0);
|
2019-03-29 14:54:34 +00:00
|
|
|
~Account();
|
|
|
|
|
2019-03-31 21:05:09 +00:00
|
|
|
void connect();
|
|
|
|
void disconnect();
|
|
|
|
|
|
|
|
Shared::ConnectionState getState() const;
|
|
|
|
QString getName() const;
|
2019-04-02 21:58:43 +00:00
|
|
|
QString getLogin() const;
|
|
|
|
QString getServer() const;
|
|
|
|
QString getPassword() const;
|
2019-04-07 20:14:15 +00:00
|
|
|
QString getResource() const;
|
|
|
|
Shared::Availability getAvailability() const;
|
|
|
|
|
|
|
|
void setName(const QString& p_name);
|
|
|
|
void setLogin(const QString& p_login);
|
|
|
|
void setServer(const QString& p_server);
|
|
|
|
void setPassword(const QString& p_password);
|
|
|
|
void setResource(const QString& p_resource);
|
|
|
|
void setAvailability(Shared::Availability avail);
|
2019-04-09 22:01:25 +00:00
|
|
|
QString getFullJid() const;
|
2019-04-11 14:58:59 +00:00
|
|
|
void sendMessage(const Shared::Message& data);
|
2019-04-21 19:17:04 +00:00
|
|
|
void requestArchive(const QString& jid, int count, const QString& before);
|
2019-03-31 21:05:09 +00:00
|
|
|
|
|
|
|
signals:
|
|
|
|
void connectionStateChanged(int);
|
2019-04-07 20:14:15 +00:00
|
|
|
void availabilityChanged(int);
|
2019-04-03 21:23:51 +00:00
|
|
|
void addGroup(const QString& name);
|
|
|
|
void removeGroup(const QString& name);
|
2019-04-07 20:14:15 +00:00
|
|
|
void addContact(const QString& jid, const QString& group, const QMap<QString, QVariant>& data);
|
2019-04-06 10:14:32 +00:00
|
|
|
void removeContact(const QString& jid);
|
|
|
|
void removeContact(const QString& jid, const QString& group);
|
2019-04-07 20:14:15 +00:00
|
|
|
void changeContact(const QString& jid, const QMap<QString, QVariant>& data);
|
2019-04-07 14:02:41 +00:00
|
|
|
void addPresence(const QString& jid, const QString& name, const QMap<QString, QVariant>& data);
|
|
|
|
void removePresence(const QString& jid, const QString& name);
|
2019-04-11 14:58:59 +00:00
|
|
|
void message(const Shared::Message& data);
|
2019-03-31 21:05:09 +00:00
|
|
|
|
2019-03-29 14:54:34 +00:00
|
|
|
private:
|
2019-03-30 20:13:13 +00:00
|
|
|
QString name;
|
2019-04-13 20:38:20 +00:00
|
|
|
std::map<QString, QString> achiveQueries;
|
2019-03-29 14:54:34 +00:00
|
|
|
QXmppClient client;
|
2019-04-07 20:14:15 +00:00
|
|
|
QXmppConfiguration config;
|
|
|
|
QXmppPresence presence;
|
2019-03-31 21:05:09 +00:00
|
|
|
Shared::ConnectionState state;
|
2019-04-06 10:14:32 +00:00
|
|
|
std::map<QString, std::set<QString>> groups;
|
2019-04-12 15:22:10 +00:00
|
|
|
QXmppCarbonManager* cm;
|
2019-04-13 20:38:20 +00:00
|
|
|
QXmppMamManager* am;
|
2019-04-17 20:08:56 +00:00
|
|
|
std::map<QString, Contact*> contacts;
|
2019-03-31 21:05:09 +00:00
|
|
|
|
|
|
|
private slots:
|
|
|
|
void onClientConnected();
|
2019-04-02 15:46:18 +00:00
|
|
|
void onClientDisconnected();
|
2019-04-19 09:12:12 +00:00
|
|
|
|
2019-04-03 21:23:51 +00:00
|
|
|
void onRosterReceived();
|
2019-04-07 14:02:41 +00:00
|
|
|
void onRosterItemAdded(const QString& bareJid);
|
|
|
|
void onRosterItemChanged(const QString& bareJid);
|
|
|
|
void onRosterItemRemoved(const QString& bareJid);
|
|
|
|
void onRosterPresenceChanged(const QString& bareJid, const QString& resource);
|
2019-04-19 09:12:12 +00:00
|
|
|
|
2019-04-07 14:02:41 +00:00
|
|
|
void onPresenceReceived(const QXmppPresence& presence);
|
2019-04-09 15:04:08 +00:00
|
|
|
void onMessageReceived(const QXmppMessage& message);
|
2019-04-19 09:12:12 +00:00
|
|
|
|
2019-04-12 15:22:10 +00:00
|
|
|
void onCarbonMessageReceived(const QXmppMessage& message);
|
|
|
|
void onCarbonMessageSent(const QXmppMessage& message);
|
2019-04-19 09:12:12 +00:00
|
|
|
|
2019-04-13 20:38:20 +00:00
|
|
|
void onMamMessageReceived(const QString& bareJid, const QXmppMessage& message);
|
|
|
|
void onMamResultsReceived(const QString &queryId, const QXmppResultSetReply &resultSetReply, bool complete);
|
2019-04-19 09:12:12 +00:00
|
|
|
|
|
|
|
void onContactGroupAdded(const QString& group);
|
|
|
|
void onContactGroupRemoved(const QString& group);
|
|
|
|
void onContactNameChanged(const QString& name);
|
|
|
|
void onContactSubscriptionStateChanged(Shared::SubscriptionState state);
|
2019-04-06 10:14:32 +00:00
|
|
|
|
|
|
|
private:
|
|
|
|
void addedAccount(const QString &bareJid);
|
2019-04-13 20:38:20 +00:00
|
|
|
bool handleChatMessage(const QXmppMessage& msg, bool outgoing = false, bool forwarded = false, bool guessing = false);
|
2019-04-19 09:12:12 +00:00
|
|
|
void addToGroup(const QString& jid, const QString& group);
|
|
|
|
void removeFromGroup(const QString& jid, const QString& group);
|
|
|
|
Shared::SubscriptionState castSubscriptionState(QXmppRosterIq::Item::SubscriptionType qs) const;
|
2019-03-29 14:54:34 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif // CORE_ACCOUNT_H
|