mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-07-15 23:12:14 -07:00
fix segfault that happens when account tab is closed (#5474)
This commit is contained in:
parent
d09b9eb533
commit
23bd18a04c
19 changed files with 332 additions and 121 deletions
72
cockatrice/src/server/user/user_list_manager.h
Normal file
72
cockatrice/src/server/user/user_list_manager.h
Normal file
|
|
@ -0,0 +1,72 @@
|
|||
#ifndef COCKATRICE_USER_LIST_MANAGER_H
|
||||
#define COCKATRICE_USER_LIST_MANAGER_H
|
||||
|
||||
#include "../chat_view/user_list_proxy.h"
|
||||
#include "pb/serverinfo_user.pb.h"
|
||||
|
||||
#include <QMap>
|
||||
#include <QWidget>
|
||||
|
||||
class AbstractClient;
|
||||
class Event_AddToList;
|
||||
class Event_ListRooms;
|
||||
class Event_RemoveFromList;
|
||||
class Event_UserJoined;
|
||||
class Event_UserLeft;
|
||||
class Response;
|
||||
class ServerInfo_User;
|
||||
class TabSupervisor;
|
||||
|
||||
class UserListManager : public QWidget, public UserlistProxy
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
private:
|
||||
AbstractClient *client;
|
||||
ServerInfo_User *ownUserInfo;
|
||||
QMap<QString, ServerInfo_User> onlineUsers, buddyUsers, ignoredUsers;
|
||||
|
||||
private slots:
|
||||
void setOwnUserInfo(const ServerInfo_User &userInfo);
|
||||
void populateInitialOnlineUsers();
|
||||
void processListUsersResponse(const Response &response);
|
||||
void processUserJoinedEvent(const Event_UserJoined &event);
|
||||
void processUserLeftEvent(const Event_UserLeft &event);
|
||||
void buddyListReceived(const QList<ServerInfo_User> &_buddyList);
|
||||
void ignoreListReceived(const QList<ServerInfo_User> &_ignoreList);
|
||||
void processAddToListEvent(const Event_AddToList &event);
|
||||
void processRemoveFromListEvent(const Event_RemoveFromList &event);
|
||||
|
||||
public:
|
||||
explicit UserListManager(AbstractClient *_client, QWidget *parent = nullptr);
|
||||
~UserListManager() override;
|
||||
|
||||
[[nodiscard]] QMap<QString, ServerInfo_User> getAllUsersList() const
|
||||
{
|
||||
return onlineUsers;
|
||||
}
|
||||
[[nodiscard]] QMap<QString, ServerInfo_User> getBuddyList() const
|
||||
{
|
||||
return buddyUsers;
|
||||
}
|
||||
[[nodiscard]] QMap<QString, ServerInfo_User> getIgnoreList() const
|
||||
{
|
||||
return ignoredUsers;
|
||||
}
|
||||
|
||||
bool isOwnUserRegistered() const override;
|
||||
QString getOwnUsername() const override;
|
||||
bool isUserBuddy(const QString &userName) const override;
|
||||
bool isUserIgnored(const QString &userName) const override;
|
||||
const ServerInfo_User *getOnlineUser(const QString &userName) const override;
|
||||
|
||||
public slots:
|
||||
void handleConnect();
|
||||
void handleDisconnect();
|
||||
|
||||
signals:
|
||||
void userLeft(const QString &userName);
|
||||
void userJoined(const ServerInfo_User &userInfo);
|
||||
};
|
||||
|
||||
#endif // COCKATRICE_USER_LIST_MANAGER_H
|
||||
Loading…
Add table
Add a link
Reference in a new issue