make enum for Participant.flags

This commit is contained in:
HanzZ 2013-01-23 19:41:56 +01:00
parent cc64a76c8b
commit 1af263f488
4 changed files with 25 additions and 8 deletions

View file

@ -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.

View file

@ -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;

View file

@ -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) {

View file

@ -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) {