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!
100 lines
2.8 KiB
C++
100 lines
2.8 KiB
C++
/*
|
|
* 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>
|
|
|
|
#include <libsupport/KeyMap.h>
|
|
|
|
#include "AppConstants.h"
|
|
#include "ChatCommand.h"
|
|
#include "Contact.h"
|
|
#include "Conversation.h"
|
|
#include "Notifier.h"
|
|
#include "ProtocolLooper.h"
|
|
#include "User.h"
|
|
|
|
class ChatProtocol;
|
|
class RosterItem;
|
|
class ProtocolLooper;
|
|
|
|
|
|
typedef KeyMap<bigtime_t, ProtocolLooper*> ProtocolLoopers;
|
|
typedef KeyMap<BString, bigtime_t> AccountInstances;
|
|
typedef KeyMap<BString, bool> BoolMap;
|
|
|
|
|
|
class Server: public BMessageFilter, public Notifier {
|
|
public:
|
|
Server();
|
|
void Quit();
|
|
void LoginAll();
|
|
void Login(ProtocolLooper* looper);
|
|
|
|
virtual filter_result Filter(BMessage* message, BHandler** target);
|
|
filter_result ImMessage(BMessage* msg);
|
|
void ImError(BMessage* msg);
|
|
|
|
void AddProtocolLooper(bigtime_t instanceId,
|
|
ChatProtocol* cayap);
|
|
void RemoveProtocolLooper(bigtime_t instanceId);
|
|
ProtocolLooper* GetProtocolLooper(bigtime_t instanceId);
|
|
|
|
AccountInstances GetAccounts();
|
|
AccountInstances GetActiveAccounts();
|
|
|
|
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);
|
|
|
|
CommandMap Commands(int64 instance);
|
|
ChatCommand* CommandById(BString id, int64 instance);
|
|
|
|
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);
|
|
|
|
void _ProtocolNotification(ProtocolLooper* looper,
|
|
BString title, BString desc,
|
|
notification_type type=B_INFORMATION_NOTIFICATION);
|
|
void _SendNotification(BString title, BString content,
|
|
BString id, BBitmap* icon=NULL,
|
|
notification_type type=B_INFORMATION_NOTIFICATION);
|
|
|
|
void _ReplicantStatusNotify(UserStatus status);
|
|
|
|
ProtocolLoopers fLoopers;
|
|
AccountInstances fAccounts;
|
|
BoolMap fAccountEnabled;
|
|
bool fStarted;
|
|
|
|
CommandMap fCommands;
|
|
BObjectList<BMessage> fUserItems;
|
|
};
|
|
|
|
#endif // _SERVER_H
|