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.
|
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 _PROTOCOL_MANAGER_H
|
|
|
|
#define _PROTOCOL_MANAGER_H
|
2010-05-07 04:47:10 -05:00
|
|
|
|
|
|
|
#include <Path.h>
|
|
|
|
#include <String.h>
|
|
|
|
|
2010-05-16 16:02:50 -05:00
|
|
|
#include <libsupport/KeyMap.h>
|
2010-05-08 14:35:28 -05:00
|
|
|
|
2010-05-07 04:47:10 -05:00
|
|
|
#include "CayaProtocol.h"
|
2010-05-16 16:02:50 -05:00
|
|
|
#include "CayaProtocolAddOn.h"
|
2010-05-07 04:47:10 -05:00
|
|
|
|
|
|
|
class BBitmap;
|
2010-05-16 16:02:50 -05:00
|
|
|
class BDirectory;
|
|
|
|
class BHandler;
|
2010-05-07 04:47:10 -05:00
|
|
|
|
2010-05-20 16:31:55 -05:00
|
|
|
class ProtocolManager {
|
2010-05-07 04:47:10 -05:00
|
|
|
public:
|
2010-05-16 16:02:50 -05:00
|
|
|
void Init(BDirectory dir, BHandler* target);
|
|
|
|
|
|
|
|
static ProtocolManager* Get();
|
|
|
|
|
2010-05-28 12:11:16 -05:00
|
|
|
uint32 CountProtocolAddOns() const;
|
|
|
|
CayaProtocolAddOn* ProtocolAddOnAt(uint32 i) const;
|
|
|
|
CayaProtocolAddOn* ProtocolAddOn(const char* signature);
|
2010-05-16 16:02:50 -05:00
|
|
|
|
2010-05-28 12:11:16 -05:00
|
|
|
uint32 CountProtocolInstances() const;
|
|
|
|
CayaProtocol* ProtocolInstanceAt(uint32 i) const;
|
2010-05-16 16:02:50 -05:00
|
|
|
CayaProtocol* ProtocolInstance(bigtime_t identifier);
|
|
|
|
|
|
|
|
void AddAccount(CayaProtocolAddOn* addOn,
|
2010-05-20 16:31:55 -05:00
|
|
|
const char* account,
|
|
|
|
BHandler* target);
|
2010-05-16 16:02:50 -05:00
|
|
|
|
|
|
|
private:
|
2010-05-28 12:11:16 -05:00
|
|
|
typedef KeyMap<BString, CayaProtocolAddOn*> AddOnMap;
|
|
|
|
typedef KeyMap<bigtime_t, CayaProtocol*> ProtocolMap;
|
|
|
|
|
2010-05-16 16:02:50 -05:00
|
|
|
ProtocolManager();
|
2010-05-20 16:31:55 -05:00
|
|
|
void _GetAccounts(CayaProtocolAddOn* addOn,
|
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
|
|
|
const char* subProtocol,
|
2010-05-20 16:31:55 -05:00
|
|
|
BHandler* target);
|
2010-05-16 16:02:50 -05:00
|
|
|
|
|
|
|
AddOnMap fAddOnMap;
|
|
|
|
ProtocolMap fProtocolMap;
|
2010-05-07 04:47:10 -05:00
|
|
|
};
|
2010-05-16 16:02:50 -05:00
|
|
|
|
|
|
|
#endif // _PROTOCOL_MANAGER_H
|