ICQ: Update sent capabilities (SSI).
[centerim.git] / libicq2000 / src / SNAC-GEN.cpp
blobfa254122b19281910b1867ce5e7268b38c735735
1 /*
2 * SNAC - General Family
4 * Copyright (C) 2001 Barnaby Gray <barnaby@beedesign.co.uk>
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.
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.
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
22 #include "SNAC-GEN.h"
24 #include "TLV.h"
25 #include "buffer.h"
27 namespace ICQ2000 {
29 // --------------- Generic (Family 0x0001) ------------
31 void ServerReadySNAC::ParseBody(Buffer& b) {
32 /* The body of the server ready SNAC seems
33 * to be a list of the SNAC families the server
34 * will accept - the client is then expected
35 * to send back a list of those it wants
36 * - basically ignore this for the moment :-)
38 unsigned short cap;
39 while(b.beforeEnd())
40 b >> cap;
44 void RequestRateInfoSNAC::OutputBody(Buffer& b) const {
45 // empty
48 void RateInfoSNAC::ParseBody(Buffer& b) {
50 // shamelessly not parsing any of this :-(
51 b.advance(179);
52 unsigned short n;
53 b >> n;
54 for (unsigned short a = 0; a < n; a++) {
55 unsigned short major, minor;
56 b >> major
57 >> minor;
60 b.advance(68);
64 void RateInfoAckSNAC::OutputBody(Buffer& b) const {
65 b << (unsigned short)0x0001
66 << (unsigned short)0x0002
67 << (unsigned short)0x0003
68 << (unsigned short)0x0004
69 << (unsigned short)0x0005;
72 void RateInfoChangeSNAC::ParseBody(Buffer& b) {
73 b >> m_code;
74 b >> m_rateclass;
75 b >> m_windowsize;
76 b >> m_clear;
77 b >> m_alert;
78 b >> m_limit;
79 b >> m_disconnect;
80 b >> m_currentavg;
81 b >> m_maxavg;
82 b.advance(5);
85 void CapabilitiesSNAC::OutputBody(Buffer& b) const {
86 /* doesn't seem any need currently to do more
87 * than copy the official client
89 unsigned short v1 = 0x0001, v3 = 0x0003, v4 = 0x0004;
90 b << SNAC_FAM_GEN << v3
91 << SNAC_FAM_LOC << v1
92 << SNAC_FAM_BUD << v1
93 << SNAC_FAM_SRV << v1
94 << SNAC_FAM_MSG << v1
95 << SNAC_FAM_INV << v1
96 << SNAC_FAM_BOS << v1
97 << SNAC_FAM_LUP << v1
98 << SNAC_FAM_SBL << v4;
101 void CapAckSNAC::ParseBody(Buffer& b) {
102 /* server sends back the list from ServerReady again
103 * but with versions of families included
104 * - again ignore for the moment
106 unsigned short cap, ver;
107 while(b.beforeEnd()) {
108 b >> cap
109 >> ver;
114 SetStatusSNAC::SetStatusSNAC(unsigned short status, bool web_aware)
115 : m_status(status), m_sendextra(false), m_web_aware(web_aware) { }
117 void SetStatusSNAC::OutputBody(Buffer& b) const {
118 StatusTLV stlv(ALLOWDIRECT_EVERYONE, (m_web_aware ? WEBAWARE_WEBAWARE : WEBAWARE_NORMAL), m_status);
119 b << stlv;
120 if (m_sendextra) {
121 UnknownTLV utlv;
122 b << utlv;
123 LANDetailsTLV ltlv(m_ip, m_port);
124 b << ltlv;
128 void SetStatusSNAC::setSendExtra(bool b) { m_sendextra = b; }
130 void SetStatusSNAC::setIP(unsigned int ip) { m_ip = ip; }
132 void SetStatusSNAC::setPort(unsigned short port) { m_port = port; }
134 void SetIdleSNAC::OutputBody(Buffer& b) const {
135 /* don't know what this value means exactly */
136 b << (unsigned int)0x00000000;
139 void ClientReadySNAC::OutputBody(Buffer& b) const {
140 /* related to capabilities again
141 * - figure this out sometime
143 b << 0x00010003
144 << 0x0110028a
145 << 0x00020001
146 << 0x0101028a
147 << 0x00030001
148 << 0x0110028a
149 << 0x00150001
150 << 0x0110028a
151 << 0x00040001
152 << 0x0110028a
153 << 0x00060001
154 << 0x0110028a
155 << 0x00090001
156 << 0x0110028a
157 << 0x000a0001
158 << 0x0110028a
159 << 0x00130004
160 << 0x01100629;
163 void PersonalInfoRequestSNAC::OutputBody(Buffer& b) const {
164 // empty
167 void UserInfoSNAC::ParseBody(Buffer& b) {
168 m_userinfo.Parse(b);
171 void MOTDSNAC::ParseBody(Buffer& b) {
172 b >> m_status;
174 /* as far as I know only one TLV follows,
175 * but we'll treat it as a list
177 TLVList tlvlist;
178 tlvlist.Parse(b, TLV_ParseMode_Channel02, (short unsigned int)-1);
179 if (tlvlist.exists(TLV_WebAddress)) {
180 WebAddressTLV *t = (WebAddressTLV*)tlvlist[TLV_WebAddress];
181 m_url = t->Value();