00001 /* 00002 00003 Copyright (C) 2005-2007 by Peter Dimov. 00004 00005 This file is part of Calitko (http://www.calitko.org). 00006 00007 Calitko is free software; you can redistribute it and/or modify 00008 it under the terms of the GNU General Public License as published by 00009 the Free Software Foundation; either version 2 of the License, or 00010 (at your option) any later version. 00011 00012 Calitko is distributed in the hope that it will be useful, 00013 but WITHOUT ANY WARRANTY; without even the implied warranty of 00014 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00015 GNU General Public License for more details. 00016 00017 You should have received a copy of the GNU General Public License 00018 along with Calitko; if not, write to the Free Software 00019 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 00020 00021 */ 00022 00023 #ifndef QUERYROUTINGPATCH_H 00024 #define QUERYROUTINGPATCH_H 00025 00026 #include "QueryRouting.h" 00027 00028 // Open containing namespaces: 00029 namespace Gnutella { 00030 namespace Packets { 00032 00033 class QueryRoutingPatch : public QueryRouting 00034 { 00035 public: 00036 enum Compressor { 00037 noCompression = 0x0, 00038 ZLIB = 0x1 00039 }; 00040 00041 static QueryRoutingPatch & castFrom (Packet & packet) { return dynamic_cast <QueryRoutingPatch &> (packet); } 00042 static const QueryRoutingPatch & castFrom (const Packet & packet) { return dynamic_cast <const QueryRoutingPatch &> (packet); } 00043 00044 QueryRoutingPatch (const QByteArray &rawHeader, const QByteArray &rawPayload); 00045 QueryRoutingPatch (quint8 seqNo, quint8 seqSize, Compressor compressor, quint8 entryBits, const QByteArray &data); 00046 ~QueryRoutingPatch(); 00047 00048 Packet* copy() const { return new QueryRoutingPatch (*this); } 00049 00050 QString name() const { return QString ("QueryRoutingPatch"); } 00051 00052 quint8 seqNo() const { return p.seqNo; } 00053 quint8 seqSize() const { return p.seqSize; } 00054 Compressor compressor() const { return p.compressor; } 00055 quint8 entryBits() const { return p.entryBits; } 00056 QByteArray data() const { return p.data; } 00057 00058 protected: 00059 bool prepareReadPayload (const QByteArray &rawPayload); 00060 void readPayload (QDataStream &stream); 00061 int prepareWritePayload() const; 00062 void writePayload (QDataStream &stream) const; 00063 00064 private: 00065 struct Data 00066 { 00067 quint8 seqNo; 00068 quint8 seqSize; 00069 Compressor compressor; 00070 quint8 entryBits; 00071 QByteArray data; 00072 } p; 00073 }; 00074 00075 // Close containing namespaces: 00076 } // namespace Packets 00077 } // namespace Gnutella 00079 00080 #endif // QUERYROUTINGPATCH_H