2020-06-14 21:23:43 +00:00
|
|
|
/*
|
|
|
|
* Squawk messenger.
|
|
|
|
* Copyright (C) 2019 Yury Gubich <blue@macaw.me>
|
|
|
|
*
|
|
|
|
* This program is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation, either version 3 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef CORE_ROSTERHANDLER_H
|
|
|
|
#define CORE_ROSTERHANDLER_H
|
|
|
|
|
|
|
|
#include <QObject>
|
|
|
|
#include <QSet>
|
|
|
|
#include <QString>
|
|
|
|
#include <QDateTime>
|
|
|
|
|
|
|
|
#include <list>
|
|
|
|
#include <map>
|
|
|
|
#include <set>
|
|
|
|
|
|
|
|
#include <QXmppBookmarkSet.h>
|
|
|
|
#include <QXmppMucManager.h>
|
|
|
|
#include <QXmppRosterIq.h>
|
|
|
|
|
2022-08-25 22:49:49 +00:00
|
|
|
#include <shared/enums.h>
|
2020-06-14 21:23:43 +00:00
|
|
|
#include <shared/message.h>
|
|
|
|
#include <core/contact.h>
|
|
|
|
#include <core/conference.h>
|
2023-03-10 18:43:31 +00:00
|
|
|
#include <core/delayManager/manager.h>
|
2020-06-14 21:23:43 +00:00
|
|
|
|
|
|
|
namespace Core {
|
|
|
|
|
|
|
|
|
|
|
|
class Account;
|
|
|
|
|
|
|
|
class RosterHandler : public QObject
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
public:
|
|
|
|
RosterHandler(Account* account);
|
|
|
|
~RosterHandler();
|
|
|
|
|
|
|
|
void addContactRequest(const QString& jid, const QString& name, const QSet<QString>& groups);
|
|
|
|
void removeContactRequest(const QString& jid);
|
|
|
|
void addContactToGroupRequest(const QString& jid, const QString& groupName);
|
|
|
|
void removeContactFromGroupRequest(const QString& jid, const QString& groupName);
|
|
|
|
|
|
|
|
void removeRoomRequest(const QString& jid);
|
|
|
|
void addRoomRequest(const QString& jid, const QString& nick, const QString& password, bool autoJoin);
|
2020-06-20 22:26:30 +00:00
|
|
|
void handleOffline();
|
2020-06-14 21:23:43 +00:00
|
|
|
|
|
|
|
Core::Contact* getContact(const QString& jid);
|
|
|
|
Core::Conference* getConference(const QString& jid);
|
|
|
|
Core::RosterItem* getRosterItem(const QString& jid);
|
|
|
|
Core::Contact* addOutOfRosterContact(const QString& jid);
|
|
|
|
|
|
|
|
void storeConferences();
|
|
|
|
void clearConferences();
|
2022-12-19 15:43:24 +00:00
|
|
|
|
|
|
|
void initialize();
|
2023-03-16 19:38:05 +00:00
|
|
|
void clear();
|
2020-06-14 21:23:43 +00:00
|
|
|
|
|
|
|
private slots:
|
|
|
|
void onRosterReceived();
|
|
|
|
void onRosterItemAdded(const QString& bareJid);
|
|
|
|
void onRosterItemChanged(const QString& bareJid);
|
|
|
|
void onRosterItemRemoved(const QString& bareJid);
|
|
|
|
|
|
|
|
void onMucRoomAdded(QXmppMucRoom* room);
|
|
|
|
void onMucJoinedChanged(bool joined);
|
|
|
|
void onMucAutoJoinChanged(bool autoJoin);
|
|
|
|
void onMucNickNameChanged(const QString& nickName);
|
|
|
|
void onMucSubjectChanged(const QString& subject);
|
|
|
|
void onMucAddParticipant(const QString& nickName, const QMap<QString, QVariant>& data);
|
|
|
|
void onMucChangeParticipant(const QString& nickName, const QMap<QString, QVariant>& data);
|
|
|
|
void onMucRemoveParticipant(const QString& nickName);
|
|
|
|
|
|
|
|
void bookmarksReceived(const QXmppBookmarkSet& bookmarks);
|
|
|
|
|
|
|
|
void onContactGroupAdded(const QString& group);
|
|
|
|
void onContactGroupRemoved(const QString& group);
|
|
|
|
void onContactNameChanged(const QString& name);
|
|
|
|
void onContactSubscriptionStateChanged(Shared::SubscriptionState state);
|
|
|
|
void onContactAvatarChanged(Shared::Avatar, const QString& path);
|
2023-03-16 19:38:05 +00:00
|
|
|
void onContactEncryptionChanged(bool value);
|
2022-08-27 11:39:24 +00:00
|
|
|
void onPepSupportedChanged(Shared::Support support);
|
2020-06-14 21:23:43 +00:00
|
|
|
|
|
|
|
private:
|
|
|
|
void addNewRoom(const QString& jid, const QString& nick, const QString& roomName, bool autoJoin);
|
|
|
|
void addToGroup(const QString& jid, const QString& group);
|
|
|
|
void removeFromGroup(const QString& jid, const QString& group);
|
|
|
|
void addedAccount(const QString &bareJid);
|
|
|
|
void handleNewRosterItem(Core::RosterItem* contact);
|
|
|
|
void handleNewContact(Core::Contact* contact);
|
|
|
|
void handleNewConference(Core::Conference* contact);
|
|
|
|
|
|
|
|
static Shared::SubscriptionState castSubscriptionState(QXmppRosterIq::Item::SubscriptionType qs);
|
|
|
|
|
|
|
|
private:
|
|
|
|
Account* acc;
|
|
|
|
std::map<QString, Contact*> contacts;
|
|
|
|
std::map<QString, Conference*> conferences;
|
|
|
|
std::map<QString, std::set<QString>> groups;
|
|
|
|
std::map<QString, QString> queuedContacts;
|
|
|
|
std::set<QString> outOfRosterContacts;
|
|
|
|
};
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif // CORE_ROSTERHANDLER_H
|