6e1ca87890
Add scaffodling support for arbitrary roles and permission-based (and varying!) UI. A new class, Role, represents a user's role in a given room, with three values: * The role's title * The role's permission-set * The role's priority The permission set is a bitmask value for various permissions (e.g., PERM_WRITE, PERM_BAN, etc), and priority is position in the hierarchy. A user with higher priority (and PERM_BAN) can ban a user with lower priority, but not vice-versa. Two users with the same priority can't ban/kick/mute each other, etc. These permissions should be used to determine what UI elements are displayed― if the user doesn't have permission to ban users, then a "Ban" button shouldn't exist. If the user is muted, they shouldn't be able to type. So on and so forth. For now, permissions are sent with a IM_ROLECHANGE message and stored by the Conversation, but aren't really in use yet. This system should be flexible groundwork to account for the varying administrative hierarchies and norms of different protocols.
85 lines
1.8 KiB
C++
85 lines
1.8 KiB
C++
/*
|
|
* Copyright 2009-2011, Andrea Anzani. All rights reserved.
|
|
* Copyright 2012, Dario Casalinuovo. All rights reserved.
|
|
* Distributed under the terms of the MIT License.
|
|
*/
|
|
#ifndef USER_H
|
|
#define USER_H
|
|
|
|
#include <String.h>
|
|
#include <Message.h>
|
|
#include <Messenger.h>
|
|
#include <ObjectList.h>
|
|
|
|
#include <libsupport/KeyMap.h>
|
|
|
|
#include "CayaConstants.h"
|
|
#include "Notifier.h"
|
|
|
|
class BBitmap;
|
|
|
|
class Conversation;
|
|
class ProtocolLooper;
|
|
class UserItem;
|
|
class UserPopUp;
|
|
|
|
|
|
typedef KeyMap<BString, Conversation*> ChatMap;
|
|
|
|
|
|
class User : public Notifier {
|
|
public:
|
|
User(BString id, BMessenger msgn);
|
|
|
|
void RegisterObserver(Conversation* chat);
|
|
void RegisterObserver(Observer* obs) { Notifier::RegisterObserver(obs); }
|
|
void UnregisterObserver(Conversation* chat);
|
|
void UnregisterObserver(Observer* obs) { Notifier::UnregisterObserver(obs); }
|
|
|
|
void ShowPopUp(BPoint where);
|
|
void DeletePopUp();
|
|
void HidePopUp();
|
|
|
|
BString GetId() const;
|
|
|
|
BMessenger Messenger() const;
|
|
void SetMessenger(BMessenger messenger);
|
|
|
|
ProtocolLooper* GetProtocolLooper() const;
|
|
void SetProtocolLooper(ProtocolLooper* looper);
|
|
BBitmap* ProtocolBitmap() const;
|
|
|
|
UserItem* GetListItem();
|
|
|
|
BString GetName() const;
|
|
BBitmap* AvatarBitmap() const;
|
|
CayaStatus GetNotifyStatus() const;
|
|
BString GetNotifyPersonalStatus() const;
|
|
|
|
void SetNotifyName(BString name);
|
|
void SetNotifyAvatarBitmap(BBitmap* bitmap);
|
|
void SetNotifyStatus(CayaStatus status);
|
|
void SetNotifyPersonalStatus(BString personalStatus);
|
|
|
|
ChatMap Conversations();
|
|
|
|
protected:
|
|
BMessenger fMessenger;
|
|
ProtocolLooper* fLooper;
|
|
|
|
UserItem* fListItem;
|
|
|
|
BString fID;
|
|
bigtime_t fInstance;
|
|
BString fName;
|
|
BString fPersonalStatus;
|
|
BBitmap* fAvatarBitmap;
|
|
CayaStatus fStatus;
|
|
UserPopUp* fPopUp;
|
|
ChatMap fConversations;
|
|
};
|
|
|
|
|
|
#endif // USER_H
|
|
|