2021-05-24 01:47:21 -05:00
|
|
|
/*
|
|
|
|
* Copyright 2021, Jaidyn Levesque <jadedctrl@teknik.io>
|
|
|
|
* All rights reserved. Distributed under the terms of the MIT license.
|
|
|
|
*/
|
|
|
|
#ifndef CONVERSATION_H
|
|
|
|
#define CONVERSATION_H
|
|
|
|
|
2021-05-24 14:48:25 -05:00
|
|
|
#include <DateTimeFormat.h>
|
2021-05-24 01:47:21 -05:00
|
|
|
#include <Messenger.h>
|
2021-05-24 14:20:57 -05:00
|
|
|
#include <Path.h>
|
2021-05-24 01:47:21 -05:00
|
|
|
|
|
|
|
#include <libsupport/KeyMap.h>
|
|
|
|
|
2021-05-27 11:15:30 -05:00
|
|
|
#include "Observer.h"
|
2021-05-31 11:56:45 -05:00
|
|
|
#include "Server.h"
|
2021-05-24 01:47:21 -05:00
|
|
|
#include "User.h"
|
|
|
|
|
2021-06-04 13:57:04 -05:00
|
|
|
class BBitmap;
|
2021-05-27 11:15:30 -05:00
|
|
|
class ConversationItem;
|
2021-05-28 22:26:32 -05:00
|
|
|
class ConversationView;
|
2021-05-24 01:47:21 -05:00
|
|
|
class ProtocolLooper;
|
|
|
|
class Server;
|
|
|
|
|
|
|
|
|
2021-05-31 11:56:45 -05:00
|
|
|
typedef KeyMap<BString, User*> UserMap;
|
2021-05-24 01:47:21 -05:00
|
|
|
|
|
|
|
|
2021-06-03 23:39:50 -05:00
|
|
|
class Conversation : public Notifier, public Observer {
|
2021-05-24 01:47:21 -05:00
|
|
|
public:
|
|
|
|
Conversation(BString id, BMessenger msgn);
|
|
|
|
|
|
|
|
BString GetId() const;
|
|
|
|
|
|
|
|
void ImMessage(BMessage* msg);
|
|
|
|
|
2021-06-03 23:39:50 -05:00
|
|
|
// Tell the ConversationView to invalidate user list
|
2021-05-24 01:47:21 -05:00
|
|
|
void ObserveString(int32 what, BString str);
|
|
|
|
void ObserveInteger(int32 what, int32 value);
|
|
|
|
void ObservePointer(int32 what, void* ptr);
|
|
|
|
|
2021-06-04 13:57:04 -05:00
|
|
|
void SetNotifySubject(const char* subject);
|
|
|
|
|
2021-05-24 01:47:21 -05:00
|
|
|
BMessenger Messenger() const;
|
|
|
|
void SetMessenger(BMessenger messenger);
|
|
|
|
|
|
|
|
ProtocolLooper* GetProtocolLooper() const;
|
|
|
|
void SetProtocolLooper(ProtocolLooper* looper);
|
|
|
|
|
2021-06-04 13:57:04 -05:00
|
|
|
BBitmap* ProtocolBitmap() const;
|
|
|
|
BBitmap* IconBitmap() const;
|
|
|
|
|
2021-05-30 20:45:24 -05:00
|
|
|
void ShowView(bool typing, bool userAction);
|
|
|
|
|
|
|
|
ConversationView* GetView();
|
|
|
|
ConversationItem* GetListItem();
|
2021-05-27 11:15:30 -05:00
|
|
|
|
2021-05-24 01:47:21 -05:00
|
|
|
BString GetName() const;
|
|
|
|
|
|
|
|
UserMap Users();
|
2021-05-31 11:56:45 -05:00
|
|
|
User* UserById(BString id);
|
2021-06-02 16:53:03 -05:00
|
|
|
|
2021-05-24 01:47:21 -05:00
|
|
|
void AddUser(User* user);
|
2021-06-02 16:53:03 -05:00
|
|
|
void RemoveUser(User* user);
|
2021-05-24 01:47:21 -05:00
|
|
|
|
|
|
|
private:
|
2021-05-24 14:20:57 -05:00
|
|
|
void _LogChatMessage(BMessage* msg);
|
2021-05-24 19:12:42 -05:00
|
|
|
BStringList _GetChatLogs();
|
2021-05-24 14:20:57 -05:00
|
|
|
void _EnsureLogPath();
|
|
|
|
|
2021-05-31 11:56:45 -05:00
|
|
|
User* _EnsureUser(BMessage* msg);
|
2021-05-24 01:47:21 -05:00
|
|
|
Server* _GetServer();
|
|
|
|
|
|
|
|
BMessenger fMessenger;
|
|
|
|
ProtocolLooper* fLooper;
|
2021-05-28 22:26:32 -05:00
|
|
|
ConversationView* fChatView;
|
2021-05-27 11:15:30 -05:00
|
|
|
ConversationItem* fConversationItem;
|
2021-05-24 01:47:21 -05:00
|
|
|
|
|
|
|
BString fID;
|
|
|
|
BString fName;
|
2021-06-04 13:57:04 -05:00
|
|
|
BString fSubject;
|
|
|
|
|
|
|
|
BBitmap* fIcon;
|
2021-05-24 01:47:21 -05:00
|
|
|
|
2021-05-24 14:20:57 -05:00
|
|
|
BPath fLogPath;
|
2021-05-24 14:48:25 -05:00
|
|
|
BDateTimeFormat fDateFormatter;
|
2021-05-24 14:20:57 -05:00
|
|
|
|
2021-05-24 01:47:21 -05:00
|
|
|
UserMap fUsers;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
#endif // CONVERSATION_H
|
|
|
|
|