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.
|
|
|
|
*/
|
2010-05-16 16:02:50 -05:00
|
|
|
#ifndef _CAYA_PROTOCOL_H
|
|
|
|
#define _CAYA_PROTOCOL_H
|
2010-05-07 04:47:10 -05:00
|
|
|
|
|
|
|
#include <Messenger.h>
|
|
|
|
|
2021-06-15 14:40:28 -05:00
|
|
|
#include "ChatCommand.h"
|
|
|
|
|
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
|
|
|
|
2010-07-10 14:28:29 -05:00
|
|
|
// Caya protocol interface version
|
|
|
|
#define CAYA_VERSION_1_PRE_ALPHA_1 0x00000001
|
|
|
|
#define CAYA_VERSION_1_ALPHA_1 0x00000100
|
|
|
|
|
|
|
|
#define CAYA_VERSION CAYA_VERSION_1_PRE_ALPHA_1
|
|
|
|
|
2021-06-15 14:40:28 -05:00
|
|
|
|
2010-05-07 04:47:10 -05:00
|
|
|
class CayaProtocolMessengerInterface {
|
2010-05-16 16:02:50 -05:00
|
|
|
public:
|
|
|
|
virtual status_t SendMessage(BMessage* message) = 0;
|
2010-05-07 04:47:10 -05:00
|
|
|
};
|
|
|
|
|
2010-05-16 16:02:50 -05:00
|
|
|
class CayaProtocol {
|
|
|
|
public:
|
2010-07-10 14:28:29 -05:00
|
|
|
//! Messenger
|
2010-05-16 16:02:50 -05:00
|
|
|
virtual status_t Init(CayaProtocolMessengerInterface*) = 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-05-20 09:32:52 -05:00
|
|
|
//! Settings menu template
|
|
|
|
virtual BMessage SettingsTemplate() = 0;
|
|
|
|
|
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
|
|
|
|
virtual BBitmap* Icon() const = 0;
|
|
|
|
|
|
|
|
//! Add-on's path
|
2021-06-01 21:43:19 -05:00
|
|
|
virtual void SetAddOnPath(BPath path) = 0;
|
|
|
|
virtual BPath AddOnPath() = 0;
|
|
|
|
|
|
|
|
//! 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
|
2010-05-16 16:02:50 -05:00
|
|
|
virtual uint32 GetEncoding() = 0;
|
2010-05-07 04:47:10 -05:00
|
|
|
|
2010-07-10 14:28:29 -05:00
|
|
|
//! Messenger interface used
|
2010-05-16 16:02:50 -05:00
|
|
|
virtual CayaProtocolMessengerInterface* MessengerInterface() const = 0;
|
2021-06-15 14:40:28 -05:00
|
|
|
|
|
|
|
//! Return a map of any custom commands
|
|
|
|
virtual CommandMap Commands() = 0;
|
2010-05-16 16:02:50 -05:00
|
|
|
};
|
2010-05-07 04:47:10 -05:00
|
|
|
|
2010-05-16 16:02:50 -05:00
|
|
|
#endif // _CAYA_PROTOCOL_H
|