ChatProtocol.h 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  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 _APP_PROTOCOL_H
  8. #define _APP_PROTOCOL_H
  9. #include <Messenger.h>
  10. #include <ObjectList.h>
  11. #include <Path.h>
  12. class BBitmap;
  13. // Chat-O-Matic protocol interface version
  14. #define APP_VERSION_1_PRE_ALPHA_1 0x00000001
  15. #define APP_VERSION_1_ALPHA_1 0x00000100
  16. #define APP_VERSION APP_VERSION_1_ALPHA_1
  17. class ChatProtocolMessengerInterface {
  18. public:
  19. virtual status_t SendMessage(BMessage* message) = 0;
  20. };
  21. class ChatProtocol {
  22. public:
  23. //! Messenger
  24. virtual status_t Init(ChatProtocolMessengerInterface*) = 0;
  25. //! Called before unloading from memory
  26. virtual status_t Shutdown() = 0;
  27. //! Process message
  28. virtual status_t Process(BMessage*) = 0;
  29. //! Change settings
  30. virtual status_t UpdateSettings(BMessage*) = 0;
  31. /*! Return a settings template
  32. Currently there are four: "account" (used when creating/editing
  33. the user's account), "create_room" & "join_room" (fairly self-evident),
  34. and "roster" (used when adding or editing a roster member. */
  35. virtual BMessage SettingsTemplate(const char* name) = 0;
  36. /*! Custom chat commands― archived ChatCommand objects
  37. Requires: String "_name", String "_desc", Bool "_proto",
  38. Message "_msg", int32s "_argtype",
  39. String "class" = "ChatCommand" */
  40. virtual BObjectList<BMessage> Commands() {
  41. return BObjectList<BMessage>();
  42. }
  43. /*! Custom menu items used in the userlist right-click menu.
  44. Archived BMenuItem with some extra slots.
  45. Requires: String "_label", Message "_msg", String "class" = "BMenuItem"
  46. Bool "x_to_protocol", Bool "x_priority", int32 "x_perms",
  47. int32 "x_target_perms", int32 "x_target_antiperms" */
  48. virtual BObjectList<BMessage> UserPopUpItems() {
  49. return BObjectList<BMessage>();
  50. }
  51. /*! Custom menu items used in the conversation-list right-click menu.
  52. Archived BMenuItem with some extra slots.
  53. Requires: String "_label", Message "_msg", String "class" = "BMenuItem"
  54. Bool "x_to_protocol", int32 "x_perms" */
  55. virtual BObjectList<BMessage> ChatPopUpItems() {
  56. return BObjectList<BMessage>();
  57. }
  58. /*! Custom menubar items (in the "Protocol" menu).
  59. Archived BMenuItem with some extra slots.
  60. Requires: String "_label", Message "_msg", String "class" = "BMenuItem"
  61. Bool "x_to_protocol" */
  62. virtual BObjectList<BMessage> MenuBarItems() {
  63. return BObjectList<BMessage>();
  64. }
  65. //! Protocol signature
  66. virtual const char* Signature() const = 0;
  67. //! Protocol name
  68. virtual const char* FriendlySignature() const = 0;
  69. //! Protocol icon
  70. virtual BBitmap* Icon() const { return NULL; }
  71. //! Add-on's path
  72. virtual void SetAddOnPath(BPath path) = 0;
  73. virtual BPath AddOnPath() = 0;
  74. //! Name of account file (leaf)
  75. virtual const char* GetName() = 0;
  76. virtual void SetName(const char* name) = 0;
  77. //! Preferred encoding of messages
  78. virtual uint32 GetEncoding() { return 0xffff; }
  79. //! Messenger interface used
  80. virtual ChatProtocolMessengerInterface* MessengerInterface() const = 0;
  81. };
  82. #endif // _APP_PROTOCOL_H