Check protocol add-ons API version

This commit is contained in:
plfiorini 2010-07-10 19:28:29 +00:00
parent a651de0f53
commit 6ef31b44f1
4 changed files with 32 additions and 10 deletions

View File

@ -8,6 +8,12 @@
#include <Messenger.h>
// 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;
@ -15,27 +21,32 @@ public:
class CayaProtocol {
public:
// Messenger
//! Messenger
virtual status_t Init(CayaProtocolMessengerInterface*) = 0;
// Called before unloading from memory
//! Called before unloading from memory
virtual status_t Shutdown() = 0;
// Process message
//! Process message
virtual status_t Process(BMessage*) = 0;
// Change settings
//! Change settings
virtual status_t UpdateSettings(BMessage*) = 0;
// Protocol information
//! Protocol signature
virtual const char* Signature() const = 0;
//! Protocol name
virtual const char* FriendlySignature() const = 0;
// Preferred encoding of messages
//! Preferred encoding of messages
virtual uint32 GetEncoding() = 0;
// Messenger interface used
//! Messenger interface used
virtual CayaProtocolMessengerInterface* MessengerInterface() const = 0;
//! Caya interface version
virtual uint32 Version() const = 0;
};
#endif // _CAYA_PROTOCOL_H

View File

@ -40,12 +40,14 @@ ProtocolManager::Init(BDirectory dir, BHandler* target)
if (id < 0)
continue;
// If add-on's API version fits then load accounts...
CayaProtocolAddOn* addOn = new CayaProtocolAddOn(id, path.Path());
if (addOn->Protocol()->Version() == CAYA_VERSION) {
fAddOnMap.AddItem(addOn->Signature(), addOn);
_GetAccounts(addOn, target);
}
}
}
ProtocolManager::ProtocolManager()

View File

@ -241,6 +241,13 @@ AIMProtocol::MessengerInterface() const
}
uint32
AIMProtocol::Version() const
{
return CAYA_VERSION_1_PRE_ALPHA_1;
}
status_t
AIMProtocol::A_LogOn()
{

View File

@ -33,6 +33,8 @@ public:
virtual CayaProtocolMessengerInterface*
MessengerInterface() const;
virtual uint32 Version() const;
static int32 WaitForData(void*);
static void GotMessage(void*, char*, int, char*);