ChatProtocolMessages.h 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443
  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 _CHAT_PROTOCOL_MESSAGES_H
  8. #define _CHAT_PROTOCOL_MESSAGES_H
  9. /**
  10. * What-codes for messages.
  11. */
  12. enum message_what_codes {
  13. //! All client <> protocol communication uses this what-code
  14. IM_MESSAGE = 'IMme',
  15. //! Used for very important (blocking) error messages
  16. IM_ERROR = 'IMer',
  17. //! Returned after a request has succeded
  18. IM_ACTION_PERFORMED = 'IMap'
  19. };
  20. /**
  21. * Valid codes for im_what field.
  22. */
  23. enum im_what_code {
  24. /*
  25. * Messages that involves server-side contact list.
  26. */
  27. //! Request a server-side contact list from protocol →Protocol
  28. IM_GET_ROSTER = 1,
  29. /*! Server-side contact list received →App
  30. Requires: Stringlist "user_id" */
  31. IM_ROSTER = 2,
  32. /*! Add a contact to the roster →Protocol
  33. The slots for this message are determined by the protocol's
  34. "roster" template (ChatProtocol::SettingsTemplate("roster")) */
  35. IM_ROSTER_ADD_CONTACT = 3,
  36. /*! Remove a contact →Protocol
  37. Requires: String "user_id" */
  38. IM_ROSTER_REMOVE_CONTACT = 4,
  39. /*! Contact(s) removed from the server-side list →App
  40. Requires: String "user_id" */
  41. IM_ROSTER_CONTACT_REMOVED = 5,
  42. /*! Edit some data on contact →Protocol
  43. The slots for this message are determined by the protocol's
  44. "roster" template (ChatProtocol::SettingsTemplate("roster")) */
  45. IM_ROSTER_EDIT_CONTACT = 6,
  46. /*
  47. * Messages related to text chat.
  48. */
  49. /*! Send a chat message →Protocol
  50. Requires: String "user_id", String "body" */
  51. IM_SEND_MESSAGE = 20,
  52. /*! Chat message has been sent →App
  53. If no user_id is specified, it's treated as a system message
  54. Requires: String "chat_id", String "body"
  55. Allows: String "user_id" */
  56. IM_MESSAGE_SENT = 21,
  57. /*! Chat message received →App
  58. To send a normal chat message, specify chat_id and user_id― if
  59. user_id is ommitted, the message is treated as a "system message"
  60. printed in chat.
  61. If chat_id is ommitted, the message is sent to the protocol's system
  62. buffer, rather than a specific conversation.
  63. face_start and face_length specify the location of formatted text in
  64. the body, and "face" is the desired font face.
  65. color_* works much the same, but with colors. Not much else to say.
  66. Requires: String "body"
  67. Allows: String "chat_id", String "user_id", String "user_name",
  68. int32s "face_start", int32s "face_length", uint16s "face"
  69. int32s "color_start", int32s "color_length",
  70. rgb_colors "color" */
  71. IM_MESSAGE_RECEIVED = 22,
  72. /*! Logs received →App
  73. Should be a message with several sub-messages of IM_MESSAGE_RECEIVED.
  74. Requires: Messages "message" */
  75. IM_LOGS_RECEIVED = 23,
  76. /*
  77. * Messages related changes in general users.
  78. */
  79. /*! User's nick has changed →App
  80. Requires: String "user_id", String "user_name" */
  81. IM_USER_NICKNAME_SET = 40,
  82. /*! Received new status for user →App
  83. Requires: String "user_id", int32/UserStatus "status" */
  84. IM_USER_STATUS_SET = 41,
  85. /*! User's avatar icon was changed →App
  86. Requires: String "user_id", Ref "ref" */
  87. IM_USER_AVATAR_SET = 42,
  88. /*
  89. * Messages related to contact's information received from protocols.
  90. */
  91. /*! Get contact information →Protocol
  92. Requires: String "user_id" */
  93. IM_GET_CONTACT_INFO = 62,
  94. /*! Received contact information →App
  95. Requires: String "user_id"
  96. Accepts: String "user_name", String "message",
  97. int32/UserStatus "status" */
  98. IM_CONTACT_INFO = 63,
  99. /*! Request contact information →Protocol
  100. Requires: String "user_id" */
  101. IM_GET_EXTENDED_CONTACT_INFO = 64,
  102. /*! Received contact information →App
  103. Requires: String "user_id",
  104. non-standard slots used by "roster" template
  105. Accepts: String "user_name" */
  106. IM_EXTENDED_CONTACT_INFO = 65,
  107. /*
  108. * Messages that involve changing own information.
  109. */
  110. /*! Change own nickname →Protocol
  111. Requires: String "user_name" */
  112. IM_SET_OWN_NICKNAME = 80,
  113. /*! Own nickname was changed →App
  114. Requires: String "user_name" */
  115. IM_OWN_NICKNAME_SET = 81,
  116. /*! Change own status →Protocol
  117. Requires: int32/UserStatus "status" */
  118. IM_SET_OWN_STATUS = 82,
  119. /*! Own status was changed →App
  120. Requires: int32/UserStatus "status" */
  121. IM_OWN_STATUS_SET = 83,
  122. /*! Get own contact information →App
  123. Must be send right after connection is established,
  124. before any room events, etc.
  125. Requires: String "user_id"
  126. Allows: String "user_name" */
  127. IM_OWN_CONTACT_INFO = 84,
  128. //! Change own avatar icon
  129. IM_SET_OWN_AVATAR = 85,
  130. /*! Own avatar icon was changed
  131. Requires: Ref "ref" */
  132. IM_OWN_AVATAR_SET = 86,
  133. /*
  134. * Contacts registration.
  135. */
  136. //! Start listening to changes in these contact's statuses [unused]
  137. IM_REGISTER_CONTACTS = 100,
  138. //! Stop listening to status changes from these contacts [unused]
  139. IM_UNREGISTER_CONTACTS = 101,
  140. /*
  141. * Authorization.
  142. */
  143. //! Ask authorization to contact [unused]
  144. IM_ASK_AUTHORIZATION = 120,
  145. //! Authorization response received from contact [unused]
  146. IM_AUTHORIZATION_RECEIVED = 121,
  147. //! Authorization request received from contact [unused]
  148. IM_AUTHORIZATION_REQUEST = 122,
  149. //! Authorization response given to contact [unused]
  150. IM_AUTHORIZATION_RESPONSE = 123,
  151. //! Contact has been authorized [unused]
  152. IM_CONTACT_AUTHORIZED = 124,
  153. /*
  154. * Miscellaneous.
  155. */
  156. //! Progress message received, could be login sequence, file transfer etc
  157. IM_PROGRESS = 140,
  158. //! Notifications
  159. IM_NOTIFICATION = 141,
  160. /*
  161. * Room membership
  162. */
  163. /*! Create an individual chat →Protocol
  164. Individual chats and rooms are really the same thing (at least according
  165. to App)― the only difference is in how they're created and joined.
  166. A "chat" should be uniquely tied to a single user, and its chat_id
  167. should be derivable from the user's ID (when sent back from
  168. CHAT_CREATED). It doesn't matter how you get this done, really.
  169. Requires: String "user_id" */
  170. IM_CREATE_CHAT = 150,
  171. /*! Chat has been created →App
  172. Requires: String "chat_id", String "user_id" */
  173. IM_CHAT_CREATED = 151,
  174. /*! Create a room →Protocol
  175. The required slots for this message are completely determined by the
  176. protocol itself― the protocol will just receive data from the
  177. "create_room" template (which is fetched via
  178. ChatProtocol::SettingsTemplate("create_room") */
  179. IM_CREATE_ROOM = 152,
  180. /*! Inform App room was created →App
  181. Just a semantically-dressed IM_ROOM_JOINED
  182. Requires: String "chat_id" */
  183. IM_ROOM_CREATED = 153,
  184. /*! Join a room →Protocol
  185. The required slots for this message are completely determined by the
  186. protocol itself― like IM_CREATE_ROOM― with the "join_room" template. */
  187. IM_JOIN_ROOM = 154,
  188. /*! Confirm the room's been joined →App
  189. Requires: String "chat_id" */
  190. IM_ROOM_JOINED = 155,
  191. /*! User wants to leave the room →Protocol
  192. Requires: String "chat_id" */
  193. IM_LEAVE_ROOM = 156,
  194. /*! User left the room →App
  195. Requires: String "chat_id" */
  196. IM_ROOM_LEFT = 157,
  197. /*! Request a room's userlist →Protocol
  198. Requires: String "chat_id" */
  199. IM_GET_ROOM_PARTICIPANTS = 158,
  200. /*! Quietly add user(s) to the chat →App
  201. Shouldn't be sent automatically on joining a room.
  202. Requires: String "chat_id", StringList "user_id"
  203. Accepts: StringList "user_name" */
  204. IM_ROOM_PARTICIPANTS = 159,
  205. /*! User has explicitly joined →App
  206. Requires: String "chat_id", String "user_id"
  207. Accepts: String "body", String "user_name" */
  208. IM_ROOM_PARTICIPANT_JOINED = 160,
  209. /*! A user left the room →App
  210. Requires: String "chat_id", String "user_id"
  211. Accepts: String "user_name", String "body" */
  212. IM_ROOM_PARTICIPANT_LEFT = 161,
  213. /*! Invite a user to a room →Protocol
  214. You can tell it succeded with IM_ROOM_PARTICIPANT_JOINED.
  215. Requires: String "chat_id", String "user_id"
  216. Accepts: String "body" */
  217. IM_ROOM_SEND_INVITE = 162,
  218. /*! Invitee explicitly refused →App
  219. Requires: String "chat_id", String "user_id"
  220. Accepts: String "user_name", String "body" */
  221. IM_ROOM_INVITE_REFUSED = 163,
  222. /*! User was invited to a room →App
  223. Requires: String "chat_id"
  224. Accepts: String "user_id", String "chat_name", String "body" */
  225. IM_ROOM_INVITE_RECEIVED = 164,
  226. /*! User accepted an invite →Protocol
  227. Requires: String "chat_id" */
  228. IM_ROOM_INVITE_ACCEPT = 165,
  229. /*! User denies an invite →Protocol
  230. Requires: String "chat_id" */
  231. IM_ROOM_INVITE_REFUSE = 166,
  232. /*
  233. * Room metadata
  234. */
  235. /*! Request a room's metadata →Protocol
  236. Requires: String "chat_id" */
  237. IM_GET_ROOM_METADATA = 170,
  238. /*! Receive room metadata →App
  239. The idea is that all other metadata-related messages should only be
  240. called either from a request, or from a change.
  241. This shouldn't be sent automatically upon joining a room.
  242. Recommendations on default room flags: Unless your protocol has remote
  243. logs, ROOM_LOG_LOCALLY and ROOM_POPULATE_LOGS should be enabled; and for
  244. multi-user rooms, ROOM_AUTOJOIN should be enabled by default (again,
  245. unless the protocol manages auto-joins). ROOM_NOTIFY_DM should be
  246. enabled by default for all rooms― ROOM_NOTIFY_ALL should be off.
  247. Requires: String "chat_id"
  248. Allows: String "chat_name", String "subject",
  249. int32 "room_default_flags", int32 "room_disallowed_flags" */
  250. IM_ROOM_METADATA = 171,
  251. /*! Set the room name →Protocol
  252. Requires: String "chat_id", String "chat_name" */
  253. IM_SET_ROOM_NAME = 172,
  254. /*! Room name has changed →Protocol
  255. Requires: String "chat_id", String "chat_name" */
  256. IM_ROOM_NAME_SET = 173,
  257. /*! Set the room subject →App
  258. Requires: String "chat_id", String "subject" */
  259. IM_SET_ROOM_SUBJECT = 174,
  260. /*! Subject has been changed →App
  261. Requires: String "chat_id", String "subject" */
  262. IM_ROOM_SUBJECT_SET = 175,
  263. /*
  264. * Room moderation
  265. */
  266. /*! A user's role has been changed →App
  267. Requires: String "role_title", int32 "role_perms",
  268. int32 "role_priority" */
  269. IM_ROOM_ROLECHANGED = 190,
  270. /*! Kick user →Protocol
  271. Requires: String "chat_id", String "user_id" */
  272. IM_ROOM_KICK_PARTICIPANT = 191,
  273. /*! A user was kicked →App
  274. Requires: String "chat_id", String "user_id"
  275. Accepts: String "user_name", String "body" */
  276. IM_ROOM_PARTICIPANT_KICKED = 192,
  277. /*! Ban user →Protocol
  278. Requires: String "chat_id", String "user_id" */
  279. IM_ROOM_BAN_PARTICIPANT = 193,
  280. /*! A user was banned →App
  281. Requires: String "chat_id", String "user_id"
  282. Accepts: String "user_name", String "body" */
  283. IM_ROOM_PARTICIPANT_BANNED = 194,
  284. /*! Unban user →Protocol */
  285. IM_ROOM_UNBAN_PARTICIPANT = 195,
  286. /*! Mute user →Protocol
  287. The result of this can be seen with IM_ROOM_ROLECHANGED.
  288. Requires: String "chat_id", String "user_id" */
  289. IM_ROOM_MUTE_PARTICIPANT = 196,
  290. /*! Unmute user →Protocol
  291. The result of this can be seen with IM_ROOM_ROLECHANGED.
  292. Requires: String "chat_id", String "user_id" */
  293. IM_ROOM_UNMUTE_PARTICIPANT = 197,
  294. /*! Deafen →Protocol
  295. The result of this can be seen with IM_ROOM_ROLECHANGED.
  296. Requires: String "chat_id", String "user_id" */
  297. IM_ROOM_DEAFEN_PARTICIPANT = 198,
  298. /*! Allow to read messages →Protocol
  299. The result of this can be seen with IM_ROOM_ROLECHANGED.
  300. Requires: String "chat_id", String "user_id" */
  301. IM_ROOM_UNDEAFEN_PARTICIPANT = 199,
  302. /*
  303. * Misc. room-related messages
  304. */
  305. /*! User started typing →App [unused]
  306. Requires: String "chat_id", String "user_id" */
  307. IM_ROOM_PARTICIPANT_STARTED_TYPING = 210,
  308. /*! User stopped typing →App [unused]
  309. Requires: String "chat_id", String "user_id" */
  310. IM_ROOM_PARTICIPANT_STOPPED_TYPING = 211,
  311. /*
  312. * Misc. UI messages
  313. */
  314. /*! Reload commands from proto →App
  315. If a protocol's command-list is dynamic (i.e., determined by its own
  316. add-ons and preferences), it makes sense to relaod commands from time
  317. to time. This forces that. */
  318. IM_PROTOCOL_RELOAD_COMMANDS = 900,
  319. /*
  320. * Special messages
  321. */
  322. //! Special message forwarded to protocol [unused]
  323. IM_SPECIAL_TO_PROTOCOL = 1000,
  324. //! Special message forwarded from protocol [unused]
  325. IM_SPECIAL_FROM_PROTOCOL = 1001,
  326. /*! Protocol is ready →App
  327. Should be sent after connection is established, initialization done */
  328. IM_PROTOCOL_READY = 1002,
  329. /*! Deletion of protocol requested →App
  330. This requests that the app delete the ChatProtocol and its
  331. ProtocolLooper― so invoking ChatProtocol::Shutdown().
  332. This should be sent by the protocol after connection errors or a
  333. disconnect, when the addon doesn't have anything left to do other
  334. than yearn for the sweet hand of death. */
  335. IM_PROTOCOL_DISABLE = 1003
  336. };
  337. #endif // _CHAT_PROTOCOL_MESSAGES_H