1 /* 2 * This file is part of Licq, an instant messaging client for UNIX. 3 * Copyright (C) 2012 Licq developers <licq-dev@googlegroups.com> 4 * 5 * Licq is free software; you can redistribute it and/or modify 6 * it under the terms of the GNU General Public License as published by 7 * the Free Software Foundation; either version 2 of the License, or 8 * (at your option) any later version. 9 * 10 * Licq is distributed in the hope that it will be useful, 11 * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 * GNU General Public License for more details. 14 * 15 * You should have received a copy of the GNU General Public License 16 * along with Licq; if not, write to the Free Software 17 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 18 */ 19 20 #ifndef LICQICQ_SOCKET_H 21 #define LICQICQ_SOCKET_H 22 23 #include <licq/socket.h> 24 25 #include <licq/buffer.h> 26 27 namespace LicqIcq 28 { 29 30 class SrvSocket : public Licq::INetSocket 31 { 32 public: 33 SrvSocket(const Licq::UserId& userId); 34 virtual ~SrvSocket(); 35 36 /// Receive a FLAP packet 37 bool receiveFlap(Licq::Buffer& buf); 38 }; 39 40 41 /** 42 * Socket for Direct Connections (Client-to-Client) 43 */ 44 class DcSocket : public Licq::TCPSocket 45 { 46 public: 47 enum ChannelType 48 { 49 ChannelUnknown = 0, 50 ChannelNormal = 1, 51 ChannelInfo = 2, 52 ChannelStatus = 3, 53 }; 54 55 DcSocket(); 56 DcSocket(const Licq::UserId& userId); 57 58 void TransferConnectionFrom(Licq::TCPSocket& from); 59 60 /** 61 * Receive a packet without blocking 62 * Check RecvBufferFull() on return to determine if packet is complete 63 * 64 * @return False on any error 65 */ 66 bool RecvPacket(); 67 ClearRecvBuffer()68 void ClearRecvBuffer() 69 { myRecvBuffer.Clear(); }; 70 RecvBufferFull()71 bool RecvBufferFull() const 72 { return myRecvBuffer.Full(); }; 73 RecvBuffer()74 Licq::Buffer& RecvBuffer() 75 { return myRecvBuffer; }; 76 setChannel(int channel)77 void setChannel(int channel) { myChannel = channel; } channel()78 int channel() const { return myChannel; } 79 Version()80 unsigned long Version() const { return (myVersion); } SetVersion(unsigned long version)81 void SetVersion(unsigned long version) { myVersion = version; } 82 83 private: 84 Licq::Buffer myRecvBuffer; 85 int myChannel; 86 unsigned short myVersion; 87 }; 88 89 } // namespace LicqIcq 90 91 #endif 92