d8d89d245e
Room flags (e.g., whether or not to auto-join, whether notifications should be sent on message receive) can now be toggled through a room's right-click menu in the room-list. Two new room flags were added for notifications as well― ROOM_NOTIFY_DM and ROOM_NOTIFY_ALL. If ROOM_NOTIFY_DM is enabled, the user will receive notifications if they are in a one-on-one chat. If ROOM_NOTIFY_ALL, they will receive notifications on every message sent to the room. The default menu items for the room's pop-up menu were moved from Templates.rdef to be built into the app. Everything else in Templates.rdef should follow suit― B_TRANSLATE can't be used in rdef files!
127 lines
2.8 KiB
C++
127 lines
2.8 KiB
C++
/*
|
|
* Copyright 2021, Jaidyn Levesque <jadedctrl@teknik.io>
|
|
* All rights reserved. Distributed under the terms of the MIT license.
|
|
*/
|
|
#ifndef CONVERSATION_H
|
|
#define CONVERSATION_H
|
|
|
|
#include <DateTimeFormat.h>
|
|
#include <Messenger.h>
|
|
#include <Path.h>
|
|
#include <StringList.h>
|
|
|
|
#include <libsupport/KeyMap.h>
|
|
|
|
#include "Observer.h"
|
|
#include "Role.h"
|
|
#include "Server.h"
|
|
#include "User.h"
|
|
|
|
class BBitmap;
|
|
class ConversationItem;
|
|
class ConversationView;
|
|
class ProtocolLooper;
|
|
class Server;
|
|
|
|
|
|
typedef KeyMap<BString, User*> UserMap;
|
|
typedef KeyMap<BString, Role*> RoleMap;
|
|
|
|
|
|
class Conversation : public Notifier, public Observer {
|
|
public:
|
|
Conversation(BString id, BMessenger msgn);
|
|
~Conversation();
|
|
|
|
BString GetId() const;
|
|
|
|
void ImMessage(BMessage* msg);
|
|
|
|
// Tell the ConversationView to invalidate user list
|
|
void ObserveString(int32 what, BString str);
|
|
void ObserveInteger(int32 what, int32 value);
|
|
void ObservePointer(int32 what, void* ptr);
|
|
|
|
void SetNotifyName(const char* name);
|
|
void SetNotifySubject(const char* subject);
|
|
bool SetNotifyIconBitmap(BBitmap* icon);
|
|
|
|
BMessenger Messenger() const;
|
|
void SetMessenger(BMessenger messenger);
|
|
|
|
ProtocolLooper* GetProtocolLooper() const;
|
|
void SetProtocolLooper(ProtocolLooper* looper);
|
|
|
|
BString GetName() const;
|
|
BString GetSubject() const;
|
|
|
|
BBitmap* ProtocolBitmap() const;
|
|
BBitmap* IconBitmap() const;
|
|
|
|
ConversationView* GetView();
|
|
void ShowView(bool typing, bool userAction);
|
|
ConversationItem* GetListItem();
|
|
|
|
UserMap Users();
|
|
User* UserById(BString id);
|
|
Contact* GetOwnContact();
|
|
|
|
void AddUser(User* user);
|
|
void RemoveUser(User* user);
|
|
|
|
void SetRole(BString id, Role* role);
|
|
Role* GetRole(BString id);
|
|
|
|
int32 GetFlags() { return fRoomFlags; }
|
|
void SetFlags(int32 flags);
|
|
int32 DisallowedFlags() { return fDisallowedFlags; }
|
|
|
|
private:
|
|
void _WarnUser(BString message);
|
|
|
|
void _LogChatMessage(BMessage* msg);
|
|
status_t _GetChatLogs(BMessage* msg);
|
|
|
|
void _CacheRoomFlags();
|
|
void _LoadRoomFlags();
|
|
|
|
void _EnsureCachePath();
|
|
User* _EnsureUser(BMessage* msg, bool implicit = true);
|
|
Role* _GetRole(BMessage* msg);
|
|
|
|
void _UpdateIcon(User* user = NULL);
|
|
bool _IsDefaultIcon(BBitmap* icon);
|
|
|
|
void _SortConversationList();
|
|
|
|
Server* _GetServer();
|
|
|
|
BMessenger fMessenger;
|
|
ProtocolLooper* fLooper;
|
|
ConversationView* fChatView;
|
|
ConversationItem* fConversationItem;
|
|
int32 fNotifyMessageCount;
|
|
int32 fNotifyMentionCount;
|
|
|
|
BString fID;
|
|
BString fName;
|
|
BString fSubject;
|
|
|
|
BBitmap* fIcon;
|
|
bool fUserIcon;
|
|
|
|
BPath fCachePath;
|
|
BDateTimeFormat fDateFormatter;
|
|
|
|
int32 fRoomFlags;
|
|
int32 fDisallowedFlags;
|
|
|
|
UserMap fUsers; // For defined, certain members of the room
|
|
BStringList fGuests; // IDs of implicitly-defined users
|
|
RoleMap fRoles;
|
|
};
|
|
|
|
|
|
#endif // CONVERSATION_H
|
|
|