Rewrite Makefile. add clean command and DEBUG option
[hama_mce-eventclient.git] / xbmcclient.h
blob79de7a1fc81d77a4a52484c17766a19db1fc85ce
1 #ifndef __XBMC_CLIENT_H__
2 #define __XBMC_CLIENT_H__
4 /*
5 * Copyright (C) 2008-2009 Team XBMC http://www.xbmc.org
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License along
18 * with this program; if not, write to the Free Software Foundation, Inc.,
19 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
22 #include <stdio.h>
23 #include <stdlib.h>
24 #include <string.h>
25 #include <sys/types.h>
26 #ifdef _WIN32
27 #include <winsock.h>
28 #else
29 #include <sys/socket.h>
30 #include <netinet/in.h>
31 #include <netdb.h>
32 #include <arpa/inet.h>
33 #endif
34 #include <vector>
35 #include <iostream>
36 #include <fstream>
37 #include <time.h>
39 #define STD_PORT 9777
41 #define MS_ABSOLUTE 0x01
42 //#define MS_RELATIVE 0x02
44 #define BTN_USE_NAME 0x01
45 #define BTN_DOWN 0x02
46 #define BTN_UP 0x04
47 #define BTN_USE_AMOUNT 0x08
48 #define BTN_QUEUE 0x10
49 #define BTN_NO_REPEAT 0x20
50 #define BTN_VKEY 0x40
51 #define BTN_AXIS 0x80
53 #define PT_HELO 0x01
54 #define PT_BYE 0x02
55 #define PT_BUTTON 0x03
56 #define PT_MOUSE 0x04
57 #define PT_PING 0x05
58 #define PT_BROADCAST 0x06
59 #define PT_NOTIFICATION 0x07
60 #define PT_BLOB 0x08
61 #define PT_LOG 0x09
62 #define PT_ACTION 0x0A
63 #define PT_DEBUG 0xFF
65 #define ICON_NONE 0x00
66 #define ICON_JPEG 0x01
67 #define ICON_PNG 0x02
68 #define ICON_GIF 0x03
70 #define MAX_PACKET_SIZE 1024
71 #define HEADER_SIZE 32
72 #define MAX_PAYLOAD_SIZE (MAX_PACKET_SIZE - HEADER_SIZE)
74 #define MAJOR_VERSION 2
75 #define MINOR_VERSION 0
77 #define LOGDEBUG 0
78 #define LOGINFO 1
79 #define LOGNOTICE 2
80 #define LOGWARNING 3
81 #define LOGERROR 4
82 #define LOGSEVERE 5
83 #define LOGFATAL 6
84 #define LOGNONE 7
86 #define ACTION_EXECBUILTIN 0x01
87 #define ACTION_BUTTON 0x02
89 class CAddress
91 private:
92 struct sockaddr_in m_Addr;
93 public:
94 CAddress(int Port = STD_PORT)
96 m_Addr.sin_family = AF_INET;
97 m_Addr.sin_port = htons(Port);
98 m_Addr.sin_addr.s_addr = INADDR_ANY;
99 memset(m_Addr.sin_zero, '\0', sizeof m_Addr.sin_zero);
102 CAddress(const char *Address, int Port = STD_PORT)
104 m_Addr.sin_port = htons(Port);
106 struct hostent *h;
107 if (Address == NULL || (h=gethostbyname(Address)) == NULL)
109 if (Address != NULL)
110 printf("Error: Get host by name\n");
112 m_Addr.sin_addr.s_addr = INADDR_ANY;
113 m_Addr.sin_family = AF_INET;
115 else
117 m_Addr.sin_family = h->h_addrtype;
118 m_Addr.sin_addr = *((struct in_addr *)h->h_addr);
120 memset(m_Addr.sin_zero, '\0', sizeof m_Addr.sin_zero);
123 void SetPort(int port)
125 m_Addr.sin_port = htons(port);
128 const sockaddr *GetAddress()
130 return ((struct sockaddr *)&m_Addr);
133 bool Bind(int Sockfd)
135 return (bind(Sockfd, (struct sockaddr *)&m_Addr, sizeof m_Addr) == 0);
139 class XBMCClientUtils
141 public:
142 XBMCClientUtils() {}
143 ~XBMCClientUtils() {}
144 static unsigned int GetUniqueIdentifier()
146 static time_t id = time(NULL);
147 return id;
150 static void Clean()
152 #ifdef _WIN32
153 WSACleanup();
154 #endif
157 static bool Initialize()
159 #ifdef _WIN32
160 WSADATA wsaData;
161 if (WSAStartup(MAKEWORD(1, 1), &wsaData))
162 return false;
163 #endif
164 return true;
168 class CPacket
170 /* Base class that implements a single event packet.
172 - Generic packet structure (maximum 1024 bytes per packet)
173 - Header is 32 bytes long, so 992 bytes available for payload
174 - large payloads can be split into multiple packets using H4 and H5
175 H5 should contain total no. of packets in such a case
176 - H6 contains length of P1, which is limited to 992 bytes
177 - if H5 is 0 or 1, then H4 will be ignored (single packet msg)
178 - H7 must be set to zeros for now
180 -----------------------------
181 | -H1 Signature ("XBMC") | - 4 x CHAR 4B
182 | -H2 Version (eg. 2.0) | - 2 x UNSIGNED CHAR 2B
183 | -H3 PacketType | - 1 x UNSIGNED SHORT 2B
184 | -H4 Sequence number | - 1 x UNSIGNED LONG 4B
185 | -H5 No. of packets in msg | - 1 x UNSIGNED LONG 4B
186 | -H6 Payload size | - 1 x UNSIGNED SHORT 2B
187 | -H7 Client's unique token | - 1 x UNSIGNED LONG 4B
188 | -H8 Reserved | - 10 x UNSIGNED CHAR 10B
189 |---------------------------|
190 | -P1 payload | -
191 -----------------------------
193 public:
194 CPacket()
196 m_PacketType = 0;
198 virtual ~CPacket()
201 bool Send(int Socket, CAddress &Addr, unsigned int UID = XBMCClientUtils::GetUniqueIdentifier())
203 if (m_Payload.size() == 0)
204 ConstructPayload();
205 bool SendSuccessfull = true;
206 int NbrOfPackages = (m_Payload.size() / MAX_PAYLOAD_SIZE) + 1;
207 int Send = 0;
208 int Sent = 0;
209 int Left = m_Payload.size();
210 for (int Package = 1; Package <= NbrOfPackages; Package++)
212 if (Left > MAX_PAYLOAD_SIZE)
214 Send = MAX_PAYLOAD_SIZE;
215 Left -= Send;
217 else
219 Send = Left;
220 Left = 0;
223 ConstructHeader(m_PacketType, NbrOfPackages, Package, Send, UID, m_Header);
224 char t[MAX_PACKET_SIZE];
225 int i, j;
226 for (i = 0; i < 32; i++)
227 t[i] = m_Header[i];
229 for (j = 0; j < Send; j++)
230 t[(32 + j)] = m_Payload[j + Sent];
232 int rtn = sendto(Socket, t, (32 + Send), 0, Addr.GetAddress(), sizeof(struct sockaddr));
234 if (rtn != (32 + Send))
235 SendSuccessfull = false;
237 Sent += Send;
239 return SendSuccessfull;
241 protected:
242 char m_Header[HEADER_SIZE];
243 unsigned short m_PacketType;
245 std::vector<char> m_Payload;
247 static void ConstructHeader(int PacketType, int NumberOfPackets, int CurrentPacket, unsigned short PayloadSize, unsigned int UniqueToken, char *Header)
249 sprintf(Header, "XBMC");
250 for (int i = 4; i < HEADER_SIZE; i++)
251 Header[i] = 0;
252 Header[4] = MAJOR_VERSION;
253 Header[5] = MINOR_VERSION;
254 if (CurrentPacket == 1)
256 Header[6] = ((PacketType & 0xff00) >> 8);
257 Header[7] = (PacketType & 0x00ff);
259 else
261 Header[6] = ((PT_BLOB & 0xff00) >> 8);
262 Header[7] = (PT_BLOB & 0x00ff);
264 Header[8] = ((CurrentPacket & 0xff000000) >> 24);
265 Header[9] = ((CurrentPacket & 0x00ff0000) >> 16);
266 Header[10] = ((CurrentPacket & 0x0000ff00) >> 8);
267 Header[11] = (CurrentPacket & 0x000000ff);
269 Header[12] = ((NumberOfPackets & 0xff000000) >> 24);
270 Header[13] = ((NumberOfPackets & 0x00ff0000) >> 16);
271 Header[14] = ((NumberOfPackets & 0x0000ff00) >> 8);
272 Header[15] = (NumberOfPackets & 0x000000ff);
274 Header[16] = ((PayloadSize & 0xff00) >> 8);
275 Header[17] = (PayloadSize & 0x00ff);
277 Header[18] = ((UniqueToken & 0xff000000) >> 24);
278 Header[19] = ((UniqueToken & 0x00ff0000) >> 16);
279 Header[20] = ((UniqueToken & 0x0000ff00) >> 8);
280 Header[21] = (UniqueToken & 0x000000ff);
283 virtual void ConstructPayload()
287 class CPacketHELO : public CPacket
289 /************************************************************************/
290 /* Payload format */
291 /* %s - device name (max 128 chars) */
292 /* %c - icontype ( 0=>NOICON, 1=>JPEG , 2=>PNG , 3=>GIF ) */
293 /* %s - my port ( 0=>not listening ) */
294 /* %d - reserved1 ( 0 ) */
295 /* %d - reserved2 ( 0 ) */
296 /* XX - imagedata ( can span multiple packets ) */
297 /************************************************************************/
298 private:
299 std::vector<char> m_DeviceName;
300 unsigned short m_IconType;
301 char *m_IconData;
302 unsigned short m_IconSize;
303 public:
304 virtual void ConstructPayload()
306 m_Payload.clear();
308 for (unsigned int i = 0; i < m_DeviceName.size(); i++)
309 m_Payload.push_back(m_DeviceName[i]);
311 m_Payload.push_back('\0');
313 m_Payload.push_back(m_IconType);
315 m_Payload.push_back(0);
316 m_Payload.push_back('\0');
318 for (int j = 0; j < 8; j++)
319 m_Payload.push_back(0);
321 for (int ico = 0; ico < m_IconSize; ico++)
322 m_Payload.push_back(m_IconData[ico]);
325 CPacketHELO(const char *DevName, unsigned short IconType, const char *IconFile = NULL) : CPacket()
327 m_PacketType = PT_HELO;
329 unsigned int len = strlen(DevName);
330 for (unsigned int i = 0; i < len; i++)
331 m_DeviceName.push_back(DevName[i]);
333 m_IconType = IconType;
335 if (IconType == ICON_NONE || IconFile == NULL)
337 m_IconData = NULL;
338 m_IconSize = 0;
339 return;
342 std::ifstream::pos_type size;
344 std::ifstream file (IconFile, std::ios::in|std::ios::binary|std::ios::ate);
345 if (file.is_open())
347 size = file.tellg();
348 m_IconData = new char [size];
349 file.seekg (0, std::ios::beg);
350 file.read (m_IconData, size);
351 file.close();
352 m_IconSize = size;
354 else
356 m_IconType = ICON_NONE;
357 m_IconSize = 0;
361 virtual ~CPacketHELO()
363 m_DeviceName.clear();
364 if (m_IconData)
365 free(m_IconData);
369 class CPacketNOTIFICATION : public CPacket
371 /************************************************************************/
372 /* Payload format: */
373 /* %s - caption */
374 /* %s - message */
375 /* %c - icontype ( 0=>NOICON, 1=>JPEG , 2=>PNG , 3=>GIF ) */
376 /* %d - reserved ( 0 ) */
377 /* XX - imagedata ( can span multiple packets ) */
378 /************************************************************************/
379 private:
380 std::vector<char> m_Title;
381 std::vector<char> m_Message;
382 unsigned short m_IconType;
383 char *m_IconData;
384 unsigned short m_IconSize;
385 public:
386 virtual void ConstructPayload()
388 m_Payload.clear();
390 for (unsigned int i = 0; i < m_Title.size(); i++)
391 m_Payload.push_back(m_Title[i]);
393 m_Payload.push_back('\0');
395 for (unsigned int i = 0; i < m_Message.size(); i++)
396 m_Payload.push_back(m_Message[i]);
398 m_Payload.push_back('\0');
400 m_Payload.push_back(m_IconType);
402 for (int i = 0; i < 4; i++)
403 m_Payload.push_back(0);
405 for (int ico = 0; ico < m_IconSize; ico++)
406 m_Payload.push_back(m_IconData[ico]);
409 CPacketNOTIFICATION(const char *Title, const char *Message, unsigned short IconType, const char *IconFile = NULL) : CPacket()
411 m_PacketType = PT_NOTIFICATION;
412 m_IconData = NULL;
413 m_IconSize = 0;
414 unsigned int len = 0;
415 if (Title != NULL)
417 len = strlen(Title);
418 for (unsigned int i = 0; i < len; i++)
419 m_Title.push_back(Title[i]);
422 if (Message != NULL)
424 len = strlen(Message);
425 for (unsigned int i = 0; i < len; i++)
426 m_Message.push_back(Message[i]);
428 m_IconType = IconType;
430 if (IconType == ICON_NONE || IconFile == NULL)
431 return;
433 std::ifstream::pos_type size;
435 std::ifstream file (IconFile, std::ios::in|std::ios::binary|std::ios::ate);
436 if (file.is_open())
438 size = file.tellg();
439 m_IconData = new char [size];
440 file.seekg (0, std::ios::beg);
441 file.read (m_IconData, size);
442 file.close();
443 m_IconSize = size;
445 else
446 m_IconType = ICON_NONE;
449 virtual ~CPacketNOTIFICATION()
451 m_Title.clear();
452 m_Message.clear();
453 if (m_IconData)
454 free(m_IconData);
458 class CPacketBUTTON : public CPacket
460 /************************************************************************/
461 /* Payload format */
462 /* %i - button code */
463 /* %i - flags 0x01 => use button map/name instead of code */
464 /* 0x02 => btn down */
465 /* 0x04 => btn up */
466 /* 0x08 => use amount */
467 /* 0x10 => queue event */
468 /* 0x20 => do not repeat */
469 /* 0x40 => virtual key */
470 /* 0x40 => axis key */
471 /* %i - amount ( 0 => 65k maps to -1 => 1 ) */
472 /* %s - device map (case sensitive and required if flags & 0x01) */
473 /* "KB" - Standard keyboard map */
474 /* "XG" - Xbox Gamepad */
475 /* "R1" - Xbox Remote */
476 /* "R2" - Xbox Universal Remote */
477 /* "LI:devicename" - valid LIRC device map where 'devicename' */
478 /* is the actual name of the LIRC device */
479 /* "JS<num>:joyname" - valid Joystick device map where */
480 /* 'joyname' is the name specified in */
481 /* the keymap. JS only supports button code */
482 /* and not button name currently (!0x01). */
483 /* %s - button name (required if flags & 0x01) */
484 /************************************************************************/
485 private:
486 std::vector<char> m_DeviceMap;
487 std::vector<char> m_Button;
488 unsigned short m_ButtonCode;
489 unsigned short m_Amount;
490 unsigned short m_Flags;
491 public:
492 virtual void ConstructPayload()
494 m_Payload.clear();
496 if (m_Button.size() != 0)
498 if (!(m_Flags & BTN_USE_NAME)) // If the BTN_USE_NAME isn't flagged for some reason
499 m_Flags |= BTN_USE_NAME;
500 m_ButtonCode = 0;
502 else
503 m_Button.clear();
505 if (m_Amount > 0)
507 if (!(m_Flags & BTN_USE_AMOUNT))
508 m_Flags |= BTN_USE_AMOUNT;
510 if (!((m_Flags & BTN_DOWN) || (m_Flags & BTN_UP))) //If none of them are tagged.
511 m_Flags |= BTN_DOWN;
513 m_Payload.push_back(((m_ButtonCode & 0xff00) >> 8));
514 m_Payload.push_back( (m_ButtonCode & 0x00ff));
516 m_Payload.push_back(((m_Flags & 0xff00) >> 8) );
517 m_Payload.push_back( (m_Flags & 0x00ff));
519 m_Payload.push_back(((m_Amount & 0xff00) >> 8) );
520 m_Payload.push_back( (m_Amount & 0x00ff));
523 for (unsigned int i = 0; i < m_DeviceMap.size(); i++)
524 m_Payload.push_back(m_DeviceMap[i]);
526 m_Payload.push_back('\0');
528 for (unsigned int i = 0; i < m_Button.size(); i++)
529 m_Payload.push_back(m_Button[i]);
531 m_Payload.push_back('\0');
534 CPacketBUTTON(const char *Button, const char *DeviceMap, unsigned short Flags, unsigned short Amount = 0) : CPacket()
536 m_PacketType = PT_BUTTON;
537 m_Flags = Flags;
538 m_ButtonCode = 0;
539 m_Amount = Amount;
541 unsigned int len = strlen(DeviceMap);
542 for (unsigned int i = 0; i < len; i++)
543 m_DeviceMap.push_back(DeviceMap[i]);
545 len = strlen(Button);
546 for (unsigned int i = 0; i < len; i++)
547 m_Button.push_back(Button[i]);
550 CPacketBUTTON(unsigned short ButtonCode, const char *DeviceMap, unsigned short Flags, unsigned short Amount = 0) : CPacket()
552 m_PacketType = PT_BUTTON;
553 m_Flags = Flags;
554 m_ButtonCode = ButtonCode;
555 m_Amount = Amount;
557 unsigned int len = strlen(DeviceMap);
558 for (unsigned int i = 0; i < len; i++)
559 m_DeviceMap.push_back(DeviceMap[i]);
562 CPacketBUTTON(unsigned short ButtonCode, unsigned short Flags, unsigned short Amount = 0) : CPacket()
564 m_PacketType = PT_BUTTON;
565 m_Flags = Flags;
566 m_ButtonCode = ButtonCode;
567 m_Amount = Amount;
570 // Used to send a release event
571 CPacketBUTTON() : CPacket()
573 m_PacketType = PT_BUTTON;
574 m_Flags = BTN_UP;
575 m_Amount = 0;
576 m_ButtonCode = 0;
579 virtual ~CPacketBUTTON()
581 m_DeviceMap.clear();
582 m_Button.clear();
585 inline unsigned short GetFlags() { return m_Flags; }
586 inline unsigned short GetButtonCode() { return m_ButtonCode; }
589 class CPacketPING : public CPacket
591 /************************************************************************/
592 /* no payload */
593 /************************************************************************/
594 public:
595 CPacketPING() : CPacket()
597 m_PacketType = PT_PING;
599 virtual ~CPacketPING()
603 class CPacketBYE : public CPacket
605 /************************************************************************/
606 /* no payload */
607 /************************************************************************/
608 public:
609 CPacketBYE() : CPacket()
611 m_PacketType = PT_BYE;
613 virtual ~CPacketBYE()
617 class CPacketMOUSE : public CPacket
619 /************************************************************************/
620 /* Payload format */
621 /* %c - flags */
622 /* - 0x01 absolute position */
623 /* %i - mousex (0-65535 => maps to screen width) */
624 /* %i - mousey (0-65535 => maps to screen height) */
625 /************************************************************************/
626 private:
627 unsigned short m_X;
628 unsigned short m_Y;
629 unsigned char m_Flag;
630 public:
631 CPacketMOUSE(int X, int Y, unsigned char Flag = MS_ABSOLUTE)
633 m_PacketType = PT_MOUSE;
634 m_Flag = Flag;
635 m_X = X;
636 m_Y = Y;
639 virtual void ConstructPayload()
641 m_Payload.clear();
643 m_Payload.push_back(m_Flag);
645 m_Payload.push_back(((m_X & 0xff00) >> 8));
646 m_Payload.push_back( (m_X & 0x00ff));
648 m_Payload.push_back(((m_Y & 0xff00) >> 8));
649 m_Payload.push_back( (m_Y & 0x00ff));
652 virtual ~CPacketMOUSE()
656 class CPacketLOG : public CPacket
658 /************************************************************************/
659 /* Payload format */
660 /* %c - log type */
661 /* %s - message */
662 /************************************************************************/
663 private:
664 std::vector<char> m_Message;
665 unsigned char m_LogLevel;
666 bool m_AutoPrintf;
667 public:
668 CPacketLOG(int LogLevel, const char *Message, bool AutoPrintf = true)
670 m_PacketType = PT_LOG;
672 unsigned int len = strlen(Message);
673 for (unsigned int i = 0; i < len; i++)
674 m_Message.push_back(Message[i]);
676 m_LogLevel = LogLevel;
677 m_AutoPrintf = AutoPrintf;
680 virtual void ConstructPayload()
682 m_Payload.clear();
684 m_Payload.push_back( (m_LogLevel & 0x00ff) );
686 if (m_AutoPrintf)
688 char* str=&m_Message[0];
689 printf("%s\n", str);
691 for (unsigned int i = 0; i < m_Message.size(); i++)
692 m_Payload.push_back(m_Message[i]);
694 m_Payload.push_back('\0');
697 virtual ~CPacketLOG()
701 class CPacketACTION : public CPacket
703 /************************************************************************/
704 /* Payload format */
705 /* %c - action type */
706 /* %s - action message */
707 /************************************************************************/
708 private:
709 unsigned char m_ActionType;
710 std::vector<char> m_Action;
711 public:
712 CPacketACTION(const char *Action, unsigned char ActionType = ACTION_EXECBUILTIN)
714 m_PacketType = PT_ACTION;
716 m_ActionType = ActionType;
717 unsigned int len = strlen(Action);
718 for (unsigned int i = 0; i < len; i++)
719 m_Action.push_back(Action[i]);
722 virtual void ConstructPayload()
724 m_Payload.clear();
726 m_Payload.push_back(m_ActionType);
727 for (unsigned int i = 0; i < m_Action.size(); i++)
728 m_Payload.push_back(m_Action[i]);
730 m_Payload.push_back('\0');
733 virtual ~CPacketACTION()
737 class CXBMCClient
739 private:
740 CAddress m_Addr;
741 int m_Socket;
742 unsigned int m_UID;
743 public:
744 CXBMCClient(const char *IP = "127.0.0.1", int Port = 9777, int Socket = -1, unsigned int UID = 0)
746 m_Addr = CAddress(IP, Port);
747 if (Socket == -1)
748 m_Socket = socket(AF_INET, SOCK_DGRAM, 0);
749 else
750 m_Socket = Socket;
752 if (UID)
753 m_UID = UID;
754 else
755 m_UID = XBMCClientUtils::GetUniqueIdentifier();
758 void SendNOTIFICATION(const char *Title, const char *Message, unsigned short IconType, const char *IconFile = NULL)
760 if (m_Socket < 0)
761 return;
763 CPacketNOTIFICATION notification(Title, Message, IconType, IconFile);
764 notification.Send(m_Socket, m_Addr, m_UID);
767 void SendHELO(const char *DevName, unsigned short IconType, const char *IconFile = NULL)
769 if (m_Socket < 0)
770 return;
772 CPacketHELO helo(DevName, IconType, IconFile);
773 helo.Send(m_Socket, m_Addr, m_UID);
776 void SendBYE()
778 if (m_Socket < 0)
779 return;
781 CPacketBYE bye;
782 bye.Send(m_Socket, m_Addr, m_UID);
785 void SendButton(const char *Button, const char *DeviceMap, unsigned short Flags, unsigned short Amount = 0)
787 if (m_Socket < 0)
788 return;
790 CPacketBUTTON button(Button, DeviceMap, Flags, Amount);
791 button.Send(m_Socket, m_Addr, m_UID);
794 void SendButton(unsigned short ButtonCode, const char *DeviceMap, unsigned short Flags, unsigned short Amount = 0)
796 if (m_Socket < 0)
797 return;
799 CPacketBUTTON button(ButtonCode, DeviceMap, Flags, Amount);
800 button.Send(m_Socket, m_Addr, m_UID);
803 void SendButton(unsigned short ButtonCode, unsigned Flags, unsigned short Amount = 0)
805 if (m_Socket < 0)
806 return;
808 CPacketBUTTON button(ButtonCode, Flags, Amount);
809 button.Send(m_Socket, m_Addr, m_UID);
812 void SendMOUSE(int X, int Y, unsigned char Flag = MS_ABSOLUTE)
814 if (m_Socket < 0)
815 return;
817 CPacketMOUSE mouse(X, Y, Flag);
818 mouse.Send(m_Socket, m_Addr, m_UID);
821 void SendLOG(int LogLevel, const char *Message, bool AutoPrintf = true)
823 if (m_Socket < 0)
824 return;
826 CPacketLOG log(LogLevel, Message, AutoPrintf);
827 log.Send(m_Socket, m_Addr, m_UID);
830 void SendACTION(const char *ActionMessage, int ActionType = ACTION_EXECBUILTIN)
832 if (m_Socket < 0)
833 return;
835 CPacketACTION action(ActionMessage, ActionType);
836 action.Send(m_Socket, m_Addr, m_UID);
840 #endif