Chat-O-Matic/application/Server.h

100 lines
2.5 KiB
C
Raw Normal View History

/*
2011-12-03 16:38:03 -06:00
* Copyright 2009-2011, Andrea Anzani. All rights reserved.
* Copyright 2009-2011, Pier Luigi Fiorini. All rights reserved.
* Distributed under the terms of the MIT License.
*/
#ifndef _SERVER_H
#define _SERVER_H
#include <Message.h>
#include <MessageFilter.h>
#include <Notification.h>
2010-05-08 14:35:28 -05:00
#include <libsupport/KeyMap.h>
2021-06-20 12:44:20 -05:00
#include "AppConstants.h"
#include "ChatCommand.h"
2021-05-23 14:39:07 -05:00
#include "Contact.h"
#include "Conversation.h"
#include "ProtocolLooper.h"
#include "User.h"
2021-06-20 12:44:20 -05:00
class ChatProtocol;
class RosterItem;
class ProtocolLooper;
typedef KeyMap<bigtime_t, ProtocolLooper*> ProtocolLoopers;
typedef KeyMap<BString, bigtime_t> AccountInstances;
class Server: public BMessageFilter {
public:
Server();
void Quit();
void LoginAll();
virtual filter_result Filter(BMessage* message, BHandler** target);
filter_result ImMessage(BMessage* msg);
void ImError(BMessage* msg);
2010-05-20 16:31:55 -05:00
void AddProtocolLooper(bigtime_t instanceId,
2021-06-20 12:44:20 -05:00
ChatProtocol* cayap);
void RemoveProtocolLooper(bigtime_t instanceId);
ProtocolLooper* GetProtocolLooper(bigtime_t instanceId);
AccountInstances
GetAccounts();
void SendProtocolMessage(BMessage* msg);
void SendAllProtocolMessage(BMessage* msg);
RosterMap Contacts() const;
Contact* ContactById(BString id, int64 instance);
void AddContact(Contact* contact, int64 instance);
UserMap Users() const;
User* UserById(BString id, int64 instance);
void AddUser(User* user, int64 instance);
ChatMap Conversations() const;
Conversation* ConversationById(BString id, int64 instance);
void AddConversation(Conversation* chat, int64 instance);
ChatCommand* CommandById(BString id, int64 instance);
2021-06-16 04:33:06 -05:00
BObjectList<BMessage> ChatPopUpItems();
BObjectList<BMessage> UserPopUpItems();
private:
ProtocolLooper* _LooperFromMessage(BMessage* message);
Contact* _EnsureContact(BMessage* message);
User* _EnsureUser(BMessage* message);
User* _EnsureUser(BString id, ProtocolLooper* protoLooper);
Contact* _GetOwnContact(BMessage* message);
Conversation* _EnsureConversation(BMessage* message);
Role* _GetRole(BMessage* msg);
void _ProtocolNotification(ProtocolLooper* looper,
BString title, BString desc,
notification_type type=B_INFORMATION_NOTIFICATION);
2021-06-20 12:44:20 -05:00
void _ReplicantStatusNotify(UserStatus status);
ProtocolLoopers fLoopers;
AccountInstances
fAccounts;
CommandMap fCommands;
BObjectList<BMessage>
fChatItems;
BObjectList<BMessage>
fUserItems;
};
#endif // _SERVER_H