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 #include "Qt.h" 00024 #include "UnknownPacket.h" 00025 00026 using namespace Gnutella::Packets; 00027 00028 UnknownPacket::UnknownPacket (const QByteArray &rawHeader, const QByteArray &rawPayload) 00029 : Packet (rawHeader, rawPayload) 00030 { 00031 parse(); 00032 } 00033 00034 UnknownPacket* UnknownPacket::copy() const 00035 { 00036 return new UnknownPacket (*this); 00037 } 00038 00039 bool UnknownPacket::prepareReadPayload (const QByteArray &) 00040 { 00041 // Always returns true. No way to check the structure of an UnknownPacket payload. 00042 return true; 00043 } 00044 void UnknownPacket::readPayload (QDataStream &) 00045 { 00046 // No need to read the payload. 00047 } 00048 int UnknownPacket::prepareWritePayload() const 00049 { 00050 // The cached payload will be returned. Payload length did not change. 00051 return payloadLength(); 00052 } 00053 void UnknownPacket::writePayload (QDataStream &) const 00054 { 00055 // No need to write the payload. The cached raw payload will be returned. 00056 } 00057 00058 QString UnknownPacket::name() const 00059 { 00060 PayloadDescriptor desc = payloadDescriptor(); 00061 if (desc == IbmcDescriptor) 00062 return QString ("IBCM"); 00063 else if (desc == OpenVendorDescriptor) 00064 return QString ("OpenVendor"); 00065 else if (desc == StandardVendorDescriptor) 00066 return QString ("StandardVendor"); 00067 return QString ("Unknown"); 00068 }