ProtocolManager.h 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. /*
  2. * Copyright 2009-2011, Andrea Anzani. All rights reserved.
  3. * Copyright 2009-2011, Pier Luigi Fiorini. All rights reserved.
  4. * Copyright 2021, Jaidyn Levesque. All rights reserved.
  5. * Distributed under the terms of the MIT License.
  6. */
  7. #ifndef _PROTOCOL_MANAGER_H
  8. #define _PROTOCOL_MANAGER_H
  9. #include <Path.h>
  10. #include <String.h>
  11. #include <libsupport/KeyMap.h>
  12. #include "ChatProtocol.h"
  13. #include "ChatProtocolAddOn.h"
  14. class BBitmap;
  15. class BDirectory;
  16. class BHandler;
  17. class MainWindow;
  18. class ProtocolSettings;
  19. class Server;
  20. class ProtocolManager {
  21. public:
  22. bool Init(BDirectory dir, BHandler* target);
  23. static ProtocolManager* Get();
  24. uint32 CountProtocolAddOns() const;
  25. ChatProtocolAddOn* ProtocolAddOnAt(uint32 i) const;
  26. ChatProtocolAddOn* ProtocolAddOn(const char* signature);
  27. uint32 CountProtocolInstances() const;
  28. ChatProtocol* ProtocolInstanceAt(uint32 i) const;
  29. ChatProtocol* ProtocolInstance(bigtime_t identifier);
  30. void AddAccount(ChatProtocolAddOn* addOn,
  31. const char* account, BHandler* target);
  32. void EnableAccount(ProtocolSettings* settings,
  33. const char* account);
  34. void DisableAccount(ProtocolSettings* settings,
  35. const char* account);
  36. void ToggleAccount(ProtocolSettings* settings,
  37. const char* account);
  38. private:
  39. typedef KeyMap<BString, ChatProtocolAddOn*> AddOnMap;
  40. typedef KeyMap<bigtime_t, ChatProtocol*> ProtocolMap;
  41. ProtocolManager();
  42. void _LoadAccounts(const char* image_path,
  43. ChatProtocolAddOn* addOn, int protoIndex,
  44. BHandler* target);
  45. void _LoadAccount(const char* imagePath,
  46. BEntry accountEntry, int protoIndex,
  47. BHandler* target);
  48. void _LoadAccount(ChatProtocolAddOn* addOn,
  49. BEntry accountEntry, BHandler* target);
  50. MainWindow* _MainWin();
  51. Server* _Server();
  52. AddOnMap fAddOnMap;
  53. ProtocolMap fProtocolMap;
  54. };
  55. #endif // _PROTOCOL_MANAGER_H