61a1f0baf1
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.
62 lines
1.4 KiB
C++
62 lines
1.4 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 _CAYA_PROTOCOL_H
|
|
#define _CAYA_PROTOCOL_H
|
|
|
|
#include <Messenger.h>
|
|
|
|
class BBitmap;
|
|
|
|
// 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
|
|
|
|
class CayaProtocolMessengerInterface {
|
|
public:
|
|
virtual status_t SendMessage(BMessage* message) = 0;
|
|
};
|
|
|
|
class CayaProtocol {
|
|
public:
|
|
//! Messenger
|
|
virtual status_t Init(CayaProtocolMessengerInterface*) = 0;
|
|
|
|
//! Called before unloading from memory
|
|
virtual status_t Shutdown() = 0;
|
|
|
|
//! Process message
|
|
virtual status_t Process(BMessage*) = 0;
|
|
|
|
//! Change settings
|
|
virtual status_t UpdateSettings(BMessage*) = 0;
|
|
|
|
//! Settings menu template
|
|
virtual BMessage SettingsTemplate() = 0;
|
|
|
|
//! Protocol signature
|
|
virtual const char* Signature() const = 0;
|
|
|
|
//! Protocol name
|
|
virtual const char* FriendlySignature() const = 0;
|
|
|
|
//! Protocol icon
|
|
virtual BBitmap* Icon() const = 0;
|
|
|
|
//! Add-on's path
|
|
virtual void SetPath(BPath path) = 0;
|
|
virtual BPath Path() = 0;
|
|
|
|
//! Preferred encoding of messages
|
|
virtual uint32 GetEncoding() = 0;
|
|
|
|
//! Messenger interface used
|
|
virtual CayaProtocolMessengerInterface* MessengerInterface() const = 0;
|
|
};
|
|
|
|
#endif // _CAYA_PROTOCOL_H
|