2010-05-07 04:47:10 -05:00
|
|
|
/*
|
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.
|
2021-06-15 14:40:28 -05:00
|
|
|
* Copyright 2021, Jaidyn Levesque. All rights reserved.
|
2010-05-07 04:47:10 -05:00
|
|
|
* Distributed under the terms of the MIT License.
|
|
|
|
*/
|
2021-06-20 12:44:20 -05:00
|
|
|
#ifndef _APP_PROTOCOL_H
|
|
|
|
#define _APP_PROTOCOL_H
|
2010-05-07 04:47:10 -05:00
|
|
|
|
|
|
|
#include <Messenger.h>
|
2021-06-20 01:24:34 -05:00
|
|
|
#include <ObjectList.h>
|
2021-06-30 15:35:40 -05:00
|
|
|
#include <Path.h>
|
2010-05-07 04:47:10 -05:00
|
|
|
|
Allow multiple protocols per add-on
Now an add-on can contain multiple protocols, and the protocol API has
changed. An add-on must now export protocol_count() and protocol_at(),
with the latter replacing protocol(). protocol_count() returning the
amount of protocols in a given add-on, and protocol_at(i) giving a
new CayaProtocol* "at" the given index.
CayaProtocol has also been changed, adding Signature(),
FriendlySignature(), Icon(), Path(), and SetPath(). The reasoning is
that different protocols (even within a single add-on) will have
different signatures and icons, so this data should be accessible from
the protocol itself.
CayaProtocolAddOn now has CountProtocols() and ProtocolAt(i), allowing
the accessing of multiple protocols. A CayaProtocolAddOn can be given a
default protocol index in the constructor, whose protocol will be
returned with Protocol(). Version() was also moved from CayaProtocol to
CayaProtocolAddOn.
2021-05-21 13:33:43 -05:00
|
|
|
class BBitmap;
|
|
|
|
|
2021-06-15 14:40:28 -05:00
|
|
|
|
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
|
|
|
|
2021-08-08 21:01:42 -05:00
|
|
|
#define APP_VERSION APP_VERSION_1_ALPHA_1
|
2010-07-10 14:28:29 -05:00
|
|
|
|
2021-06-15 14:40:28 -05:00
|
|
|
|
2021-06-20 12:44:20 -05:00
|
|
|
class ChatProtocolMessengerInterface {
|
2010-05-16 16:02:50 -05:00
|
|
|
public:
|
|
|
|
virtual status_t SendMessage(BMessage* message) = 0;
|
2010-05-07 04:47:10 -05:00
|
|
|
};
|
|
|
|
|
2021-06-20 12:44:20 -05:00
|
|
|
class ChatProtocol {
|
2010-05-16 16:02:50 -05:00
|
|
|
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-05-07 04:47:10 -05:00
|
|
|
|
2010-07-10 14:28:29 -05:00
|
|
|
//! Called before unloading from memory
|
2010-05-16 16:02:50 -05:00
|
|
|
virtual status_t Shutdown() = 0;
|
2010-05-07 04:47:10 -05:00
|
|
|
|
2010-07-10 14:28:29 -05:00
|
|
|
//! Process message
|
2010-05-16 16:02:50 -05:00
|
|
|
virtual status_t Process(BMessage*) = 0;
|
2010-05-07 04:47:10 -05:00
|
|
|
|
2010-07-10 14:28:29 -05:00
|
|
|
//! Change settings
|
2010-05-16 16:02:50 -05:00
|
|
|
virtual status_t UpdateSettings(BMessage*) = 0;
|
2010-05-07 04:47:10 -05:00
|
|
|
|
2021-07-07 10:59:56 -05:00
|
|
|
/*! 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. */
|
2021-06-17 16:51:37 -05:00
|
|
|
virtual BMessage SettingsTemplate(const char* name) = 0;
|
2021-05-20 09:32:52 -05:00
|
|
|
|
2021-07-07 10:59:56 -05:00
|
|
|
/*! Custom chat commands― archived ChatCommand objects
|
|
|
|
Requires: String "_name", String "_desc", Bool "_proto",
|
|
|
|
Message "_msg", int32s "_argtype",
|
|
|
|
String "class" = "ChatCommand" */
|
2021-06-20 01:24:34 -05:00
|
|
|
virtual BObjectList<BMessage> Commands() {
|
|
|
|
return BObjectList<BMessage>();
|
|
|
|
}
|
|
|
|
|
2021-07-07 10:59:56 -05:00
|
|
|
/*! 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" */
|
2021-08-09 10:48:45 -05:00
|
|
|
virtual BObjectList<BMessage> UserPopUpItems() {
|
|
|
|
return BObjectList<BMessage>();
|
|
|
|
}
|
2021-06-20 01:24:34 -05:00
|
|
|
|
2021-07-07 10:59:56 -05:00
|
|
|
/*! 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" */
|
2021-08-09 10:48:45 -05:00
|
|
|
virtual BObjectList<BMessage> ChatPopUpItems() {
|
|
|
|
return BObjectList<BMessage>();
|
|
|
|
}
|
2021-06-20 01:24:34 -05:00
|
|
|
|
2021-07-07 10:59:56 -05:00
|
|
|
/*! 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" */
|
2021-08-09 10:48:45 -05:00
|
|
|
virtual BObjectList<BMessage> MenuBarItems() {
|
|
|
|
return BObjectList<BMessage>();
|
|
|
|
}
|
2021-06-20 01:24:34 -05:00
|
|
|
|
2010-07-10 14:28:29 -05:00
|
|
|
//! Protocol signature
|
2010-05-16 16:02:50 -05:00
|
|
|
virtual const char* Signature() const = 0;
|
2010-07-10 14:28:29 -05:00
|
|
|
|
|
|
|
//! Protocol name
|
2010-05-16 16:02:50 -05:00
|
|
|
virtual const char* FriendlySignature() const = 0;
|
|
|
|
|
Allow multiple protocols per add-on
Now an add-on can contain multiple protocols, and the protocol API has
changed. An add-on must now export protocol_count() and protocol_at(),
with the latter replacing protocol(). protocol_count() returning the
amount of protocols in a given add-on, and protocol_at(i) giving a
new CayaProtocol* "at" the given index.
CayaProtocol has also been changed, adding Signature(),
FriendlySignature(), Icon(), Path(), and SetPath(). The reasoning is
that different protocols (even within a single add-on) will have
different signatures and icons, so this data should be accessible from
the protocol itself.
CayaProtocolAddOn now has CountProtocols() and ProtocolAt(i), allowing
the accessing of multiple protocols. A CayaProtocolAddOn can be given a
default protocol index in the constructor, whose protocol will be
returned with Protocol(). Version() was also moved from CayaProtocol to
CayaProtocolAddOn.
2021-05-21 13:33:43 -05:00
|
|
|
//! Protocol icon
|
2021-08-09 10:48:45 -05:00
|
|
|
virtual BBitmap* Icon() const { return NULL; }
|
Allow multiple protocols per add-on
Now an add-on can contain multiple protocols, and the protocol API has
changed. An add-on must now export protocol_count() and protocol_at(),
with the latter replacing protocol(). protocol_count() returning the
amount of protocols in a given add-on, and protocol_at(i) giving a
new CayaProtocol* "at" the given index.
CayaProtocol has also been changed, adding Signature(),
FriendlySignature(), Icon(), Path(), and SetPath(). The reasoning is
that different protocols (even within a single add-on) will have
different signatures and icons, so this data should be accessible from
the protocol itself.
CayaProtocolAddOn now has CountProtocols() and ProtocolAt(i), allowing
the accessing of multiple protocols. A CayaProtocolAddOn can be given a
default protocol index in the constructor, whose protocol will be
returned with Protocol(). Version() was also moved from CayaProtocol to
CayaProtocolAddOn.
2021-05-21 13:33:43 -05:00
|
|
|
|
2022-02-18 15:42:06 -06:00
|
|
|
//! Pertinent paths
|
2021-06-01 21:43:19 -05:00
|
|
|
virtual BPath AddOnPath() = 0;
|
2022-02-18 15:42:06 -06:00
|
|
|
virtual void SetAddOnPath(BPath path) = 0;
|
|
|
|
virtual void SetAccountCachePath(BPath path) { };
|
|
|
|
virtual void SetAddOnCachePath(BPath path) { };
|
2021-06-01 21:43:19 -05:00
|
|
|
|
|
|
|
//! Name of account file (leaf)
|
|
|
|
virtual const char* GetName() = 0;
|
|
|
|
virtual void SetName(const char* name) = 0;
|
Allow multiple protocols per add-on
Now an add-on can contain multiple protocols, and the protocol API has
changed. An add-on must now export protocol_count() and protocol_at(),
with the latter replacing protocol(). protocol_count() returning the
amount of protocols in a given add-on, and protocol_at(i) giving a
new CayaProtocol* "at" the given index.
CayaProtocol has also been changed, adding Signature(),
FriendlySignature(), Icon(), Path(), and SetPath(). The reasoning is
that different protocols (even within a single add-on) will have
different signatures and icons, so this data should be accessible from
the protocol itself.
CayaProtocolAddOn now has CountProtocols() and ProtocolAt(i), allowing
the accessing of multiple protocols. A CayaProtocolAddOn can be given a
default protocol index in the constructor, whose protocol will be
returned with Protocol(). Version() was also moved from CayaProtocol to
CayaProtocolAddOn.
2021-05-21 13:33:43 -05:00
|
|
|
|
2010-07-10 14:28:29 -05:00
|
|
|
//! Preferred encoding of messages
|
2021-08-09 10:48:45 -05:00
|
|
|
virtual uint32 GetEncoding() { return 0xffff; }
|
2010-05-07 04:47:10 -05:00
|
|
|
|
2010-07-10 14:28:29 -05:00
|
|
|
//! Messenger interface used
|
2021-06-20 12:44:20 -05:00
|
|
|
virtual ChatProtocolMessengerInterface* MessengerInterface() const = 0;
|
2010-05-16 16:02:50 -05:00
|
|
|
};
|
2010-05-07 04:47:10 -05:00
|
|
|
|
2021-06-20 12:44:20 -05:00
|
|
|
#endif // _APP_PROTOCOL_H
|