Chat-O-Matic/application/ChatProtocol.h

109 lines
3.2 KiB
C
Raw Permalink 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.
* Copyright 2021, Jaidyn Levesque. All rights reserved.
* Distributed under the terms of the MIT License.
*/
2021-06-20 12:44:20 -05:00
#ifndef _APP_PROTOCOL_H
#define _APP_PROTOCOL_H
#include <Messenger.h>
#include <ObjectList.h>
2021-06-30 15:35:40 -05:00
#include <Path.h>
class BBitmap;
2021-08-19 02:28:06 -05:00
// Chat-O-Matic protocol interface version
2021-06-20 12:44:20 -05:00
#define APP_VERSION_1_PRE_ALPHA_1 0x00000001
#define APP_VERSION_1_ALPHA_1 0x00000100
2010-07-10 14:28:29 -05:00
#define APP_VERSION APP_VERSION_1_ALPHA_1
2010-07-10 14:28:29 -05:00
2021-06-20 12:44:20 -05:00
class ChatProtocolMessengerInterface {
public:
virtual status_t SendMessage(BMessage* message) = 0;
};
2021-06-20 12:44:20 -05:00
class ChatProtocol {
public:
2010-07-10 14:28:29 -05:00
//! Messenger
2021-06-20 12:44:20 -05:00
virtual status_t Init(ChatProtocolMessengerInterface*) = 0;
2010-07-10 14:28:29 -05:00
//! Called before unloading from memory
virtual status_t Shutdown() = 0;
2010-07-10 14:28:29 -05:00
//! Process message
virtual status_t Process(BMessage*) = 0;
2010-07-10 14:28:29 -05:00
//! Change settings
virtual status_t UpdateSettings(BMessage*) = 0;
/*! Return a settings template
Currently there are four: "account" (used when creating/editing
the user's account), "create_room" & "join_room" (fairly self-evident),
and "roster" (used when adding or editing a roster member. */
virtual BMessage SettingsTemplate(const char* name) = 0;
/*! Custom chat commands― archived ChatCommand objects
Requires: String "_name", String "_desc", Bool "_proto",
Message "_msg", int32s "_argtype",
String "class" = "ChatCommand" */
virtual BObjectList<BMessage> Commands() {
return BObjectList<BMessage>();
}
/*! Custom menu items used in the userlist right-click menu.
Archived BMenuItem with some extra slots.
Requires: String "_label", Message "_msg", String "class" = "BMenuItem"
Bool "x_to_protocol", Bool "x_priority", int32 "x_perms",
int32 "x_target_perms", int32 "x_target_antiperms" */
virtual BObjectList<BMessage> UserPopUpItems() {
return BObjectList<BMessage>();
}
/*! Custom menu items used in the conversation-list right-click menu.
Archived BMenuItem with some extra slots.
Requires: String "_label", Message "_msg", String "class" = "BMenuItem"
Bool "x_to_protocol", int32 "x_perms" */
virtual BObjectList<BMessage> ChatPopUpItems() {
return BObjectList<BMessage>();
}
/*! Custom menubar items (in the "Protocol" menu).
Archived BMenuItem with some extra slots.
Requires: String "_label", Message "_msg", String "class" = "BMenuItem"
Bool "x_to_protocol" */
virtual BObjectList<BMessage> MenuBarItems() {
return BObjectList<BMessage>();
}
2010-07-10 14:28:29 -05:00
//! Protocol signature
virtual const char* Signature() const = 0;
2010-07-10 14:28:29 -05:00
//! Protocol name
virtual const char* FriendlySignature() const = 0;
//! Protocol icon
virtual BBitmap* Icon() const { return NULL; }
//! Pertinent paths
virtual BPath AddOnPath() = 0;
virtual void SetAddOnPath(BPath path) = 0;
virtual void SetAccountCachePath(BPath path) { };
virtual void SetAddOnCachePath(BPath path) { };
//! Name of account file (leaf)
virtual const char* GetName() = 0;
virtual void SetName(const char* name) = 0;
2010-07-10 14:28:29 -05:00
//! Preferred encoding of messages
virtual uint32 GetEncoding() { return 0xffff; }
2010-07-10 14:28:29 -05:00
//! Messenger interface used
2021-06-20 12:44:20 -05:00
virtual ChatProtocolMessengerInterface* MessengerInterface() const = 0;
};
2021-06-20 12:44:20 -05:00
#endif // _APP_PROTOCOL_H