Show moderation items in right-click user menu, by perm
This commit is contained in:
parent
6e1ca87890
commit
fe99f3d83a
|
@ -13,7 +13,8 @@ enum {
|
||||||
PTR_AVATAR_BITMAP,
|
PTR_AVATAR_BITMAP,
|
||||||
|
|
||||||
INT_ACCOUNT_STATUS,
|
INT_ACCOUNT_STATUS,
|
||||||
INT_CONTACT_STATUS
|
INT_CONTACT_STATUS,
|
||||||
|
INT_USER_PERMS
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // _NOTIFY_MESSAGE_H
|
#endif // _NOTIFY_MESSAGE_H
|
||||||
|
|
|
@ -14,16 +14,16 @@
|
||||||
// NSRBKDMNRW
|
// NSRBKDMNRW
|
||||||
// 0000000000
|
// 0000000000
|
||||||
|
|
||||||
#define PERM_WRITE 0x01
|
#define PERM_WRITE 1
|
||||||
#define PERM_READ 0x02
|
#define PERM_READ 2
|
||||||
#define PERM_NICK 0x04
|
#define PERM_NICK 4
|
||||||
#define PERM_MUTE 0x08
|
#define PERM_MUTE 8
|
||||||
#define PERM_DEAFEN 0x016
|
#define PERM_DEAFEN 16
|
||||||
#define PERM_KICK 0x032
|
#define PERM_KICK 32
|
||||||
#define PERM_BAN 0x064
|
#define PERM_BAN 64
|
||||||
#define PERM_ROLECHANGE 0x0128
|
#define PERM_ROLECHANGE 128
|
||||||
#define PERM_ROOM_SUBJECT 0x0256
|
#define PERM_ROOM_SUBJECT 256
|
||||||
#define PERM_ROOM_NAME 0x0512
|
#define PERM_ROOM_NAME 512
|
||||||
#define PERM_ALL 1023
|
#define PERM_ALL 1023
|
||||||
|
|
||||||
|
|
||||||
|
@ -34,14 +34,14 @@ public:
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
Role(BString title, uint32 perms, uint32 priority)
|
Role(BString title, int32 perms, int32 priority)
|
||||||
: fTitle(title), fPerms(perms), fPriority(priority)
|
: fTitle(title), fPerms(perms), fPriority(priority)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
BString fTitle;
|
BString fTitle;
|
||||||
uint32 fPerms; // Permissions afforded to role, as described above.
|
int32 fPerms; // Permissions afforded to role, as described above.
|
||||||
uint32 fPriority; // 'Rank' of role, with higher being greater priority.
|
int32 fPriority; // 'Rank' of role, with higher being greater priority.
|
||||||
// I.E., a user with a priority of 11 can't kick a user
|
// I.E., a user with a priority of 11 can't kick a user
|
||||||
// with a priority of 12, but can one with 10.
|
// with a priority of 12, but can one with 10.
|
||||||
// This sort of hierarchy might not be universal in
|
// This sort of hierarchy might not be universal in
|
||||||
|
|
|
@ -653,12 +653,12 @@ Server::_GetRole(BMessage* msg)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
BString title;
|
BString title;
|
||||||
uint32 perms;
|
int32 perms;
|
||||||
uint32 priority;
|
int32 priority;
|
||||||
|
|
||||||
if (msg->FindString("role_title", &title) != B_OK
|
if (msg->FindString("role_title", &title) != B_OK
|
||||||
|| msg->FindUInt32("role_perms", &perms) != B_OK
|
|| msg->FindInt32("role_perms", &perms) != B_OK
|
||||||
|| msg->FindUInt32("role_priority", &priority) != B_OK)
|
|| msg->FindInt32("role_priority", &priority) != B_OK)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
return new Role(title, perms, priority);
|
return new Role(title, perms, priority);
|
||||||
|
|
|
@ -43,6 +43,7 @@ ConversationView::ConversationView(Conversation* chat)
|
||||||
: ConversationView()
|
: ConversationView()
|
||||||
{
|
{
|
||||||
SetConversation(chat);
|
SetConversation(chat);
|
||||||
|
fUserList->SetConversation(chat);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -10,17 +10,23 @@
|
||||||
#include <Window.h>
|
#include <Window.h>
|
||||||
|
|
||||||
#include "CayaMessages.h"
|
#include "CayaMessages.h"
|
||||||
|
#include "Conversation.h"
|
||||||
|
#include "Role.h"
|
||||||
#include "User.h"
|
#include "User.h"
|
||||||
#include "UserInfoWindow.h"
|
#include "UserInfoWindow.h"
|
||||||
#include "UserItem.h"
|
#include "UserItem.h"
|
||||||
|
|
||||||
|
|
||||||
const uint32 kUserInfo = 'ULui';
|
const uint32 kUserInfo = 'ULui';
|
||||||
//const uint32 kLeaveSelectedChat = 'CVcs';
|
const uint32 kDeafenUser = 'UMdu';
|
||||||
|
const uint32 kMuteUser = 'UMmu';
|
||||||
|
const uint32 kKickUser = 'UMku';
|
||||||
|
const uint32 kBanUser = 'UMbu';
|
||||||
|
|
||||||
|
|
||||||
UserListView::UserListView(const char* name)
|
UserListView::UserListView(const char* name)
|
||||||
: BListView(name)
|
: BListView(name),
|
||||||
|
fChat(NULL)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -68,12 +74,38 @@ BPopUpMenu*
|
||||||
UserListView::_UserPopUp()
|
UserListView::_UserPopUp()
|
||||||
{
|
{
|
||||||
BPopUpMenu* menu = new BPopUpMenu("userPopUp");
|
BPopUpMenu* menu = new BPopUpMenu("userPopUp");
|
||||||
menu->AddItem(new BMenuItem("User info…" B_UTF8_ELLIPSIS,
|
menu->AddItem(new BMenuItem("User info" B_UTF8_ELLIPSIS,
|
||||||
new BMessage(kUserInfo)));
|
new BMessage(kUserInfo)));
|
||||||
menu->SetTargetForItems(this);
|
menu->SetTargetForItems(this);
|
||||||
|
|
||||||
|
// Now for the moderation items
|
||||||
|
Role* role = fChat->GetRole(fChat->OwnUserId());
|
||||||
|
int32 perms = role->fPerms;
|
||||||
|
UserItem* item = (UserItem*)ItemAt(CurrentSelection());
|
||||||
|
User* selected_user;
|
||||||
|
|
||||||
|
if (item == NULL || (selected_user = item->GetUser()) == NULL)
|
||||||
return menu;
|
return menu;
|
||||||
|
|
||||||
|
int32 selected_priority = fChat->GetRole(selected_user->GetId())->fPriority;
|
||||||
|
if (selected_priority > role->fPriority)
|
||||||
|
return menu;
|
||||||
|
|
||||||
|
if ((perms & PERM_DEAFEN) || (perms & PERM_MUTE) || (perms & PERM_KICK)
|
||||||
|
|| (perms & PERM_BAN))
|
||||||
|
menu->AddSeparatorItem();
|
||||||
|
|
||||||
|
if (perms & PERM_DEAFEN)
|
||||||
|
menu->AddItem(new BMenuItem("Deafen user", new BMessage(kDeafenUser)));
|
||||||
|
if (perms & PERM_MUTE)
|
||||||
|
menu->AddItem(new BMenuItem("Mute user", new BMessage(kMuteUser)));
|
||||||
|
if (perms & PERM_KICK)
|
||||||
|
menu->AddItem(new BMenuItem("Kick user", new BMessage(kKickUser)));
|
||||||
|
if (perms & PERM_BAN)
|
||||||
|
menu->AddItem(new BMenuItem("Ban user", new BMessage(kBanUser)));
|
||||||
|
|
||||||
|
|
||||||
|
return menu;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -8,6 +8,7 @@
|
||||||
#include <ListView.h>
|
#include <ListView.h>
|
||||||
|
|
||||||
class BPopUpMenu;
|
class BPopUpMenu;
|
||||||
|
class Conversation;
|
||||||
|
|
||||||
|
|
||||||
class UserListView : public BListView {
|
class UserListView : public BListView {
|
||||||
|
@ -18,9 +19,13 @@ public:
|
||||||
|
|
||||||
void MouseDown(BPoint where);
|
void MouseDown(BPoint where);
|
||||||
|
|
||||||
|
void SetConversation(Conversation* chat) { fChat = chat; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
BPopUpMenu* _UserPopUp();
|
BPopUpMenu* _UserPopUp();
|
||||||
BPopUpMenu* _BlankPopUp();
|
BPopUpMenu* _BlankPopUp();
|
||||||
|
|
||||||
|
Conversation* fChat;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -913,7 +913,7 @@ JabberHandler::_RoleTitle(gloox::MUCRoomRole role, gloox::MUCRoomAffiliation aff
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
uint32
|
int32
|
||||||
JabberHandler::_RolePerms(gloox::MUCRoomRole role, gloox::MUCRoomAffiliation aff)
|
JabberHandler::_RolePerms(gloox::MUCRoomRole role, gloox::MUCRoomAffiliation aff)
|
||||||
{
|
{
|
||||||
switch (role)
|
switch (role)
|
||||||
|
@ -931,7 +931,7 @@ JabberHandler::_RolePerms(gloox::MUCRoomRole role, gloox::MUCRoomAffiliation aff
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
uint32
|
int32
|
||||||
JabberHandler::_RolePriority(gloox::MUCRoomRole role, gloox::MUCRoomAffiliation aff)
|
JabberHandler::_RolePriority(gloox::MUCRoomRole role, gloox::MUCRoomAffiliation aff)
|
||||||
{
|
{
|
||||||
switch (role)
|
switch (role)
|
||||||
|
@ -1249,8 +1249,8 @@ JabberHandler::_RoleChanged(BString chat_id, BString user_id,
|
||||||
roleMsg.AddString("user_id", user_id);
|
roleMsg.AddString("user_id", user_id);
|
||||||
roleMsg.AddString("chat_id", chat_id);
|
roleMsg.AddString("chat_id", chat_id);
|
||||||
roleMsg.AddString("role_title", _RoleTitle(role, aff));
|
roleMsg.AddString("role_title", _RoleTitle(role, aff));
|
||||||
roleMsg.AddUInt32("role_perms", _RolePerms(role, aff));
|
roleMsg.AddInt32("role_perms", _RolePerms(role, aff));
|
||||||
roleMsg.AddUInt32("role_priority", _RolePriority(role, aff));
|
roleMsg.AddInt32("role_priority", _RolePriority(role, aff));
|
||||||
_SendMessage(&roleMsg);
|
_SendMessage(&roleMsg);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -135,8 +135,8 @@ private:
|
||||||
bool _MUCUserId(BString chat_id, const char* nick, BString* id);
|
bool _MUCUserId(BString chat_id, const char* nick, BString* id);
|
||||||
|
|
||||||
const char* _RoleTitle(gloox::MUCRoomRole role, gloox::MUCRoomAffiliation aff);
|
const char* _RoleTitle(gloox::MUCRoomRole role, gloox::MUCRoomAffiliation aff);
|
||||||
uint32 _RolePerms(gloox::MUCRoomRole role, gloox::MUCRoomAffiliation aff);
|
int32 _RolePerms(gloox::MUCRoomRole role, gloox::MUCRoomAffiliation aff);
|
||||||
uint32 _RolePriority(gloox::MUCRoomRole role, gloox::MUCRoomAffiliation aff);
|
int32 _RolePriority(gloox::MUCRoomRole role, gloox::MUCRoomAffiliation aff);
|
||||||
|
|
||||||
virtual void onConnect();
|
virtual void onConnect();
|
||||||
virtual void onDisconnect(gloox::ConnectionError);
|
virtual void onDisconnect(gloox::ConnectionError);
|
||||||
|
|
Ŝarĝante…
Reference in New Issue