kodi
IrssMessage.h
1 /*
2  * Copyright (C) 2005-2018 Team Kodi
3  * This file is part of Kodi - https://kodi.tv
4  *
5  * SPDX-License-Identifier: GPL-2.0-or-later
6  * See LICENSES/README.md for more information.
7  */
8 
9 #pragma once
10 
11 #include <string>
12 
16  enum IRSS_MessageType
17  {
21  IRSSMT_Unknown = 0,
22 
26  IRSSMT_RegisterClient = 1,
30  IRSSMT_UnregisterClient = 2,
31 
35  IRSSMT_RegisterRepeater = 3,
39  IRSSMT_UnregisterRepeater = 4,
40 
44  IRSSMT_LearnIR = 5,
48  IRSSMT_BlastIR = 6,
49 
53  IRSSMT_Error = 7,
54 
58  IRSSMT_ServerShutdown = 8,
62  IRSSMT_ServerSuspend = 9,
66  IRSSMT_ServerResume = 10,
67 
71  IRSSMT_RemoteEvent = 11,
75  IRSSMT_KeyboardEvent = 12,
79  IRSSMT_MouseEvent = 13,
80 
84  IRSSMT_ForwardRemoteEvent = 14,
88  IRSSMT_ForwardKeyboardEvent = 15,
92  IRSSMT_ForwardMouseEvent = 16,
93 
97  IRSSMT_AvailableReceivers = 17,
101  IRSSMT_AvailableBlasters = 18,
105  IRSSMT_ActiveReceivers = 19,
109  IRSSMT_ActiveBlasters = 20,
113  IRSSMT_DetectedReceivers = 21,
117  IRSSMT_DetectedBlasters = 22,
118  };
119 
123  enum IRSS_MessageFlags
124  {
128  IRSSMF_None = 0x0000,
129 
133  IRSSMF_Request = 0x0001,
137  IRSSMF_Response = 0x0002,
141  IRSSMF_Notify = 0x0004,
142 
146  IRSSMF_Success = 0x0008,
150  IRSSMF_Failure = 0x0010,
154  IRSSMF_Timeout = 0x0020,
155 
156  //IRSSMF_Error = 0x0040,
157 
158  //IRSSMF_DataString = 0x0080,
159  //IRSSMF_DataBytes = 0x0100,
160 
161  //IRSSMF_ForceRespond = 0x0200,
162 
166  IRSSMF_ForceNotRespond = 0x0400,
167  };
168 
170 {
171 public:
172  CIrssMessage();
173  CIrssMessage(IRSS_MessageType type, uint32_t flags);
174  CIrssMessage(IRSS_MessageType type, uint32_t flags, char* data, int size);
175  CIrssMessage(IRSS_MessageType type, uint32_t flags, const std::string& data);
176  ~CIrssMessage();
177 
178  void SetDataAsBytes(char* data, int size);
179  void SetDataAsString(const std::string& data);
180  char* ToBytes(int& size);
181  void SetType(IRSS_MessageType type);
182  void SetFlags(uint32_t flags);
183  IRSS_MessageType GetType() {return m_type;}
184  uint32_t GetFlags() {return m_flags;}
185  char* GetData() {return m_data;}
186  uint32_t GetDataSize() {return m_dataSize;}
187  static bool FromBytes(char* from, int size, CIrssMessage& message);
188 
189 private:
190  IRSS_MessageType m_type;
191  uint32_t m_flags;
192 
193  char* m_data;
194  int m_dataSize;
195 
196  void FreeData();
197 };
Definition: IrssMessage.h:169