[cosmetics] update date in GPL header
[vuplus_xbmc] / xbmc / input / windows / IrssMessage.h
1 #pragma once
2 /*
3  *      Copyright (C) 2005-2013 Team XBMC
4  *      http://xbmc.org
5  *
6  *  This Program is free software; you can redistribute it and/or modify
7  *  it under the terms of the GNU General Public License as published by
8  *  the Free Software Foundation; either version 2, or (at your option)
9  *  any later version.
10  *
11  *  This Program is distributed in the hope that it will be useful,
12  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
13  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  *  GNU General Public License for more details.
15  *
16  *  You should have received a copy of the GNU General Public License
17  *  along with XBMC; see the file COPYING.  If not, see
18  *  <http://www.gnu.org/licenses/>.
19  *
20  */
21
22 #include "utils/StdString.h"
23
24   /// <summary>
25   /// Type of message.
26   /// </summary>
27   enum IRSS_MessageType
28   {
29     /// <summary>
30     /// Unknown message type.
31     /// </summary>
32     IRSSMT_Unknown = 0,
33
34     /// <summary>
35     /// Register Client.
36     /// </summary>
37     IRSSMT_RegisterClient = 1,
38     /// <summary>
39     /// Unregister Client.
40     /// </summary>
41     IRSSMT_UnregisterClient = 2,
42
43     /// <summary>
44     /// Register Repeater.
45     /// </summary>
46     IRSSMT_RegisterRepeater = 3,
47     /// <summary>
48     /// Unregister Repeater.
49     /// </summary>
50     IRSSMT_UnregisterRepeater = 4,
51
52     /// <summary>
53     /// Learn IR Command.
54     /// </summary>
55     IRSSMT_LearnIR = 5,
56     /// <summary>
57     /// Blast IR Command.
58     /// </summary>
59     IRSSMT_BlastIR = 6,
60
61     /// <summary>
62     /// Error.
63     /// </summary>
64     IRSSMT_Error = 7,
65
66     /// <summary>
67     /// Server Shutdown.
68     /// </summary>
69     IRSSMT_ServerShutdown = 8,
70     /// <summary>
71     /// Server Suspend.
72     /// </summary>
73     IRSSMT_ServerSuspend = 9,
74     /// <summary>
75     /// Server Resume
76     /// </summary>
77     IRSSMT_ServerResume = 10,
78
79     /// <summary>
80     /// Remote Event.
81     /// </summary>
82     IRSSMT_RemoteEvent = 11,
83     /// <summary>
84     /// Keyboard Event.
85     /// </summary>
86     IRSSMT_KeyboardEvent = 12,
87     /// <summary>
88     /// Mouse Event.
89     /// </summary>
90     IRSSMT_MouseEvent = 13,
91
92     /// <summary>
93     /// Forward a Remote Event.
94     /// </summary>
95     IRSSMT_ForwardRemoteEvent = 14,
96     /// <summary>
97     /// Forward a Keyboard Event.
98     /// </summary>
99     IRSSMT_ForwardKeyboardEvent = 15,
100     /// <summary>
101     /// Forward a Mouse Event.
102     /// </summary>
103     IRSSMT_ForwardMouseEvent = 16,
104
105     /// <summary>
106     /// Available Receivers.
107     /// </summary>
108     IRSSMT_AvailableReceivers = 17,
109     /// <summary>
110     /// Available Blasters.
111     /// </summary>
112     IRSSMT_AvailableBlasters = 18,
113     /// <summary>
114     /// Active Receivers.
115     /// </summary>
116     IRSSMT_ActiveReceivers = 19,
117     /// <summary>
118     /// Active Blasters.
119     /// </summary>
120     IRSSMT_ActiveBlasters = 20,
121     /// <summary>
122     /// Detected Receivers.
123     /// </summary>
124     IRSSMT_DetectedReceivers = 21,
125     /// <summary>
126     /// Detected Blasters.
127     /// </summary>
128     IRSSMT_DetectedBlasters = 22,
129   };
130
131   /// <summary>
132   /// Flags to determine more information about the message.
133   /// </summary>
134   enum IRSS_MessageFlags
135   {
136     /// <summary>
137     /// No Flags.
138     /// </summary>
139     IRSSMF_None            = 0x0000,
140
141     /// <summary>
142     /// Message is a Request.
143     /// </summary>
144     IRSSMF_Request         = 0x0001,
145     /// <summary>
146     /// Message is a Response to a received Message.
147     /// </summary>
148     IRSSMF_Response        = 0x0002,
149     /// <summary>
150     /// Message is a Notification.
151     /// </summary>
152     IRSSMF_Notify          = 0x0004,
153
154     /// <summary>
155     /// Operation Success.
156     /// </summary>
157     IRSSMF_Success         = 0x0008,
158     /// <summary>
159     /// Operation Failure.
160     /// </summary>
161     IRSSMF_Failure         = 0x0010,
162     /// <summary>
163     /// Operation Time-Out.
164     /// </summary>
165     IRSSMF_Timeout         = 0x0020,
166
167     //IRSSMF_Error           = 0x0040,
168
169     //IRSSMF_DataString      = 0x0080,
170     //IRSSMF_DataBytes       = 0x0100,
171
172     //IRSSMF_ForceRespond    = 0x0200,
173
174     /// <summary>
175     /// Force the recipient not to respond.
176     /// </summary>
177     IRSSMF_ForceNotRespond = 0x0400,
178   };
179
180 class CIrssMessage
181 {
182 public:
183   CIrssMessage();
184   CIrssMessage(IRSS_MessageType type, uint32_t flags);
185   CIrssMessage(IRSS_MessageType type, uint32_t flags, char* data, int size);
186   CIrssMessage(IRSS_MessageType type, uint32_t flags, const CStdString& data);
187   ~CIrssMessage();
188
189   void SetDataAsBytes(char* data, int size);
190   void SetDataAsString(const CStdString& data);
191   char* ToBytes(int& size);
192   void SetType(IRSS_MessageType type);
193   void SetFlags(uint32_t flags);
194   IRSS_MessageType GetType() {return m_type;}
195   uint32_t GetFlags() {return m_flags;}
196   char* GetData() {return m_data;}
197   uint32_t GetDataSize() {return m_dataSize;}
198   static bool FromBytes(char* from, int size, CIrssMessage& message);
199
200 private:
201   IRSS_MessageType m_type;
202   uint32_t m_flags;
203
204   char* m_data;
205   int m_dataSize;
206
207   void FreeData();
208 };