2021-05-23 15:10:14 -05:00
|
|
|
/*
|
|
|
|
* Copyright 2009-2011, Andrea Anzani. All rights reserved.
|
|
|
|
* Copyright 2012, Dario Casalinuovo. All rights reserved.
|
2021-06-13 17:34:30 -05:00
|
|
|
* Copyright 2021, Jaidyn Levesque. All rights reserved.
|
2021-05-23 15:10:14 -05:00
|
|
|
* Distributed under the terms of the MIT License.
|
|
|
|
*/
|
2021-05-24 01:47:21 -05:00
|
|
|
#ifndef USER_H
|
|
|
|
#define USER_H
|
2021-05-23 15:10:14 -05:00
|
|
|
|
|
|
|
#include <String.h>
|
|
|
|
#include <Message.h>
|
|
|
|
#include <Messenger.h>
|
2021-05-24 01:47:21 -05:00
|
|
|
#include <ObjectList.h>
|
2021-06-13 17:34:30 -05:00
|
|
|
#include <Path.h>
|
2021-05-24 01:47:21 -05:00
|
|
|
|
|
|
|
#include <libsupport/KeyMap.h>
|
2021-05-23 15:10:14 -05:00
|
|
|
|
2021-06-20 12:44:20 -05:00
|
|
|
#include "AppConstants.h"
|
Support for "Roles" (user, moderator, admin, etc.)
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.
2021-06-06 00:41:45 -05:00
|
|
|
#include "Notifier.h"
|
2021-05-23 15:10:14 -05:00
|
|
|
|
|
|
|
class BBitmap;
|
|
|
|
|
2021-05-24 01:47:21 -05:00
|
|
|
class Conversation;
|
2021-05-23 15:10:14 -05:00
|
|
|
class ProtocolLooper;
|
2021-05-31 10:50:43 -05:00
|
|
|
class UserItem;
|
|
|
|
class UserPopUp;
|
2021-05-23 15:10:14 -05:00
|
|
|
|
2021-05-24 01:47:21 -05:00
|
|
|
|
|
|
|
typedef KeyMap<BString, Conversation*> ChatMap;
|
|
|
|
|
|
|
|
|
2021-05-23 15:10:14 -05:00
|
|
|
class User : public Notifier {
|
|
|
|
public:
|
|
|
|
User(BString id, BMessenger msgn);
|
|
|
|
|
2021-05-24 01:47:21 -05:00
|
|
|
void RegisterObserver(Conversation* chat);
|
|
|
|
void RegisterObserver(Observer* obs) { Notifier::RegisterObserver(obs); }
|
|
|
|
void UnregisterObserver(Conversation* chat);
|
|
|
|
void UnregisterObserver(Observer* obs) { Notifier::UnregisterObserver(obs); }
|
|
|
|
|
2021-05-23 15:10:14 -05:00
|
|
|
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;
|
|
|
|
|
2021-05-31 10:50:43 -05:00
|
|
|
UserItem* GetListItem();
|
|
|
|
|
2021-05-23 15:10:14 -05:00
|
|
|
BString GetName() const;
|
|
|
|
BBitmap* AvatarBitmap() const;
|
2021-06-20 12:44:20 -05:00
|
|
|
UserStatus GetNotifyStatus() const;
|
2021-05-23 15:10:14 -05:00
|
|
|
BString GetNotifyPersonalStatus() const;
|
|
|
|
|
|
|
|
void SetNotifyName(BString name);
|
|
|
|
void SetNotifyAvatarBitmap(BBitmap* bitmap);
|
2021-06-20 12:44:20 -05:00
|
|
|
void SetNotifyStatus(UserStatus status);
|
2021-05-23 15:10:14 -05:00
|
|
|
void SetNotifyPersonalStatus(BString personalStatus);
|
|
|
|
|
2021-05-24 01:47:21 -05:00
|
|
|
ChatMap Conversations();
|
|
|
|
|
2021-06-07 00:56:26 -05:00
|
|
|
rgb_color fItemColor;
|
|
|
|
|
2021-05-23 15:10:14 -05:00
|
|
|
protected:
|
2021-06-13 17:34:30 -05:00
|
|
|
virtual void _EnsureCachePath();
|
|
|
|
|
|
|
|
BBitmap* _GetCachedAvatar();
|
|
|
|
void _SetCachedAvatar(BBitmap* avatar);
|
|
|
|
|
2021-05-23 15:10:14 -05:00
|
|
|
BMessenger fMessenger;
|
|
|
|
ProtocolLooper* fLooper;
|
|
|
|
|
2021-05-31 10:50:43 -05:00
|
|
|
UserItem* fListItem;
|
|
|
|
|
2021-05-23 15:10:14 -05:00
|
|
|
BString fID;
|
|
|
|
BString fName;
|
|
|
|
BString fPersonalStatus;
|
|
|
|
BBitmap* fAvatarBitmap;
|
2021-06-13 17:34:30 -05:00
|
|
|
BPath fCachePath;
|
2021-06-20 12:44:20 -05:00
|
|
|
UserStatus fStatus;
|
2021-05-23 15:10:14 -05:00
|
|
|
UserPopUp* fPopUp;
|
2021-05-24 01:47:21 -05:00
|
|
|
ChatMap fConversations;
|
2021-05-23 15:10:14 -05:00
|
|
|
};
|
|
|
|
|
2021-05-24 01:47:21 -05:00
|
|
|
|
|
|
|
#endif // USER_H
|
|
|
|
|