1 /* 2 * SNAC - Message Family 3 * 4 * Copyright (C) 2001 Barnaby Gray <barnaby@beedesign.co.uk> 5 * 6 * This library is free software; you can redistribute it and/or 7 * modify it under the terms of the GNU Lesser General Public 8 * License as published by the Free Software Foundation; either 9 * version 2.1 of the License, or (at your option) any later version. 10 * 11 * This library 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 GNU 14 * Lesser General Public License for more details. 15 * 16 * You should have received a copy of the GNU Lesser General Public 17 * License along with this library; if not, write to the Free Software 18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 19 * 20 */ 21 22 #ifndef SNAC_MSG_H 23 #define SNAC_MSG_H 24 25 #include "SNAC-base.h" 26 #include "ICQ.h" 27 #include "UserInfoBlock.h" 28 #include "ICBMCookie.h" 29 #include "Capabilities.h" 30 31 namespace ICQ2000 { 32 33 // Messages (Family 0x0004) 34 const unsigned short SNAC_MSG_Error = 0x0001; 35 const unsigned short SNAC_MSG_AddICBMParameter = 0x0002; 36 const unsigned short SNAC_MSG_Send = 0x0006; 37 const unsigned short SNAC_MSG_Message = 0x0007; 38 const unsigned short SNAC_MSG_MessageACK = 0x000b; 39 const unsigned short SNAC_MSG_OfflineUser = 0x000c; 40 const unsigned short SNAC_MSG_TypingNotification = 0x0014; 41 42 // ----------------- Message (Family 0x0004) SNACs -------------- 43 44 class MsgFamilySNAC : virtual public SNAC { 45 public: Family()46 unsigned short Family() const { return SNAC_FAM_MSG; } 47 }; 48 49 class MsgAddICBMParameterSNAC : public MsgFamilySNAC, public OutSNAC { 50 private: 51 bool m_typing_notif; 52 53 protected: 54 void OutputBody(Buffer& b) const; 55 56 public: MsgAddICBMParameterSNAC(bool typing_notif)57 MsgAddICBMParameterSNAC(bool typing_notif) : m_typing_notif(typing_notif) 58 { } 59 Subtype()60 unsigned short Subtype() const { return SNAC_MSG_AddICBMParameter; } 61 }; 62 63 class MsgSendSNAC : public MsgFamilySNAC, public OutSNAC { 64 protected: 65 ICQSubType *m_icqsubtype; 66 bool m_advanced; 67 unsigned short m_seqnum; 68 ICBMCookie m_cookie; 69 Capabilities m_dest_capabilities; 70 71 void OutputBody(Buffer& b) const; 72 73 public: 74 MsgSendSNAC(ICQSubType *icqsubtype, bool ad = false); 75 76 void setSeqNum(unsigned short sn); 77 void setAdvanced(bool ad); 78 void setICBMCookie(const ICBMCookie& c); 79 void set_capabilities(const Capabilities& c); 80 Subtype()81 unsigned short Subtype() const { return SNAC_MSG_Send; } 82 }; 83 84 class MessageSNAC : public MsgFamilySNAC, public InSNAC { 85 protected: 86 87 // General fields 88 UserInfoBlock m_userinfo; 89 ICQSubType *m_icqsubtype; 90 ICBMCookie m_cookie; 91 92 void ParseBody(Buffer& b); 93 94 public: 95 MessageSNAC(); 96 MessageSNAC(const std::string &uin); 97 MessageSNAC(const std::string &uin, const std::string &reason); 98 MessageSNAC(const std::string &uin, const std::string &reason, bool granted); 99 100 ~MessageSNAC(); 101 getICQSubType()102 ICQSubType* getICQSubType() const { return m_icqsubtype; } 103 ICQSubType* grabICQSubType(); setICQSubType(ICQSubType * ist)104 void setICQSubType(ICQSubType *ist) { m_icqsubtype = ist; } setICBMCookie(const ICBMCookie & c)105 void setICBMCookie(const ICBMCookie& c) { m_cookie = c; } getICBMCookie()106 ICBMCookie getICBMCookie() const { return m_cookie; } 107 Subtype()108 unsigned short Subtype() const { return SNAC_MSG_Message; } 109 }; 110 111 class MessageACKSNAC : public MsgFamilySNAC, public InSNAC, public OutSNAC { 112 protected: 113 ICBMCookie m_cookie; 114 UINICQSubType *m_icqsubtype; 115 116 void ParseBody(Buffer& b); 117 void OutputBody(Buffer& b) const; 118 119 public: 120 MessageACKSNAC(); 121 MessageACKSNAC(ICBMCookie c, UINICQSubType *icqsubtype); 122 ~MessageACKSNAC(); 123 getICQSubType()124 UINICQSubType* getICQSubType() const { return m_icqsubtype; } getICBMCookie()125 ICBMCookie getICBMCookie() const { return m_cookie; } 126 Subtype()127 unsigned short Subtype() const { return SNAC_MSG_MessageACK; } 128 }; 129 130 class MessageOfflineUserSNAC : public MsgFamilySNAC, public InSNAC { 131 protected: 132 ICBMCookie m_cookie; 133 unsigned short m_channel; 134 unsigned int m_uin; 135 136 void ParseBody(Buffer& b); 137 138 public: 139 getICBMCookie()140 ICBMCookie getICBMCookie() const { return m_cookie; } getChannel()141 unsigned short getChannel() const { return m_channel; } 142 Subtype()143 unsigned short Subtype() const { return SNAC_MSG_OfflineUser; } getUIN()144 unsigned int getUIN() const { return m_uin; } 145 }; 146 147 class MessageTypingNotificationSNAC : public MsgFamilySNAC, public InSNAC { 148 protected: 149 ICBMCookie m_cookie; 150 unsigned short m_channel; 151 unsigned int m_uin; 152 unsigned short m_type; 153 154 void ParseBody(Buffer& b); 155 156 public: 157 getICBMCookie()158 ICBMCookie getICBMCookie() const { return m_cookie; } getChannel()159 unsigned short getChannel() const { return m_channel; } getType()160 unsigned short getType() const { return m_type; } 161 Subtype()162 unsigned short Subtype() const { return SNAC_MSG_TypingNotification; } getUIN()163 unsigned int getUIN() const { return m_uin; } 164 }; 165 166 } 167 168 #endif 169