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.
53 lines
1.3 KiB
C++
53 lines
1.3 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 _PROTOCOL_MANAGER_H
|
|
#define _PROTOCOL_MANAGER_H
|
|
|
|
#include <Path.h>
|
|
#include <String.h>
|
|
|
|
#include <libsupport/KeyMap.h>
|
|
|
|
#include "CayaProtocol.h"
|
|
#include "CayaProtocolAddOn.h"
|
|
|
|
class BBitmap;
|
|
class BDirectory;
|
|
class BHandler;
|
|
|
|
class ProtocolManager {
|
|
public:
|
|
void Init(BDirectory dir, BHandler* target);
|
|
|
|
static ProtocolManager* Get();
|
|
|
|
uint32 CountProtocolAddOns() const;
|
|
CayaProtocolAddOn* ProtocolAddOnAt(uint32 i) const;
|
|
CayaProtocolAddOn* ProtocolAddOn(const char* signature);
|
|
|
|
uint32 CountProtocolInstances() const;
|
|
CayaProtocol* ProtocolInstanceAt(uint32 i) const;
|
|
CayaProtocol* ProtocolInstance(bigtime_t identifier);
|
|
|
|
void AddAccount(CayaProtocolAddOn* addOn,
|
|
const char* account,
|
|
BHandler* target);
|
|
|
|
private:
|
|
typedef KeyMap<BString, CayaProtocolAddOn*> AddOnMap;
|
|
typedef KeyMap<bigtime_t, CayaProtocol*> ProtocolMap;
|
|
|
|
ProtocolManager();
|
|
void _GetAccounts(CayaProtocolAddOn* addOn,
|
|
const char* subProtocol,
|
|
BHandler* target);
|
|
|
|
AddOnMap fAddOnMap;
|
|
ProtocolMap fProtocolMap;
|
|
};
|
|
|
|
#endif // _PROTOCOL_MANAGER_H
|