diff --git a/include/transport/conversation.h b/include/transport/conversation.h index eb2885f8..cda549cb 100644 --- a/include/transport/conversation.h +++ b/include/transport/conversation.h @@ -33,15 +33,22 @@ class ConversationManager; /// Represents one XMPP-Legacy network conversation. class Conversation { public: + typedef enum { + PARTICIPANT_FLAG_NONE = 0, + PARTICIPANT_FLAG_MODERATOR = 1, + PARTICIPANT_FLAG_CONFLICT = 2, + PARTICIPANT_FLAG_BANNED = 4, + PARTICIPANT_FLAG_NOT_AUTHORIZED = 8, + PARTICIPANT_FLAG_ME = 16, + PARTICIPANT_FLAG_KICKED = 32 + } ParticipantFlag; + typedef struct _Participant { - int flag; + ParticipantFlag flag; int status; std::string statusMessage; } Participant; - /// Type of participants in MUC rooms. - enum ParticipantFlag {None, Moderator}; - /// Creates new conversation. /// \param conversationManager ConversationManager associated with this Conversation. @@ -70,7 +77,7 @@ class Conversation { /// \param status Current status of this participant. /// \param statusMessage Current status message of this participant. /// \param newname If participant was renamed, this variable contains his new name. - void handleParticipantChanged(const std::string &nickname, int flag, int status = Swift::StatusShow::None, const std::string &statusMessage = "", const std::string &newname = ""); + void handleParticipantChanged(const std::string &nickname, ParticipantFlag flag, int status = Swift::StatusShow::None, const std::string &statusMessage = "", const std::string &newname = ""); /// Sets XMPP user nickname in MUC rooms. diff --git a/include/transport/protocol.proto b/include/transport/protocol.proto index 316b164e..8eafcde8 100644 --- a/include/transport/protocol.proto +++ b/include/transport/protocol.proto @@ -86,6 +86,16 @@ message RoomList { repeated string name = 2; } +enum ParticipantFlag { + PARTICIPANT_FLAG_NONE = 0; + PARTICIPANT_FLAG_MODERATOR = 1; + PARTICIPANT_FLAG_CONFLICT = 2; + PARTICIPANT_FLAG_BANNED = 4; + PARTICIPANT_FLAG_NOT_AUTHORIZED = 8; + PARTICIPANT_FLAG_ME = 16; + PARTICIPANT_FLAG_KICKED = 32; +} + message Participant { required string userName = 1; required string room = 2; diff --git a/src/conversation.cpp b/src/conversation.cpp index 6074fc78..44af07b4 100644 --- a/src/conversation.cpp +++ b/src/conversation.cpp @@ -242,7 +242,7 @@ Swift::Presence::ref Conversation::generatePresence(const std::string &nick, int item.affiliation = Swift::MUCOccupant::Member; item.role = Swift::MUCOccupant::Participant; - if (flag & Moderator) { + if (flag & PARTICIPANT_FLAG_MODERATOR) { item.affiliation = Swift::MUCOccupant::Admin; item.role = Swift::MUCOccupant::Moderator; } @@ -260,7 +260,7 @@ Swift::Presence::ref Conversation::generatePresence(const std::string &nick, int return presence; } -void Conversation::handleParticipantChanged(const std::string &nick, int flag, int status, const std::string &statusMessage, const std::string &newname) { +void Conversation::handleParticipantChanged(const std::string &nick, Conversation::ParticipantFlag flag, int status, const std::string &statusMessage, const std::string &newname) { Swift::Presence::ref presence = generatePresence(nick, flag, status, statusMessage, newname); if (presence->getType() == Swift::Presence::Unavailable) { diff --git a/src/networkpluginserver.cpp b/src/networkpluginserver.cpp index dd4ced39..bb51b73e 100644 --- a/src/networkpluginserver.cpp +++ b/src/networkpluginserver.cpp @@ -625,7 +625,7 @@ void NetworkPluginServer::handleParticipantChangedPayload(const std::string &dat return; } - conv->handleParticipantChanged(payload.nickname(), payload.flag(), payload.status(), payload.statusmessage(), payload.newname()); + conv->handleParticipantChanged(payload.nickname(), (Conversation::ParticipantFlag) payload.flag(), payload.status(), payload.statusmessage(), payload.newname()); } void NetworkPluginServer::handleRoomChangedPayload(const std::string &data) {