NodeInfo.cpp

Go to the documentation of this file.
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 "NodeInfo.h"
00025 
00026 using Gnutella::NodeInfo;
00027 using Gnutella::NodeType;
00028 
00029 NodeInfo::NodeInfo()
00030  :  address(), identification(), vendorCode(), serventVersion(),
00031     type (TypeUnknown), ultrapeerNeeded (true), pongCaching(), ggep(),
00032     queryRouting(), ultrapeerQueryRouting(), dynamicQuerying(), guess(),
00033     vendorMessage(), extProbes(), byePacket(), degree (0), maxTtl (0),
00034     encoding(), freeUltrapeerSlots (-1), freeLeafSlots (-1), dailyUptime (-1)
00035 {
00036 }
00037 
00038 NodeInfo::~NodeInfo()
00039 {
00040 }
00041 
00042 QDataStream & Gnutella::operator << (QDataStream &stream, const NodeInfo &nodeInfo)
00043 {
00044     stream << nodeInfo.address;
00045     stream << nodeInfo.identification;
00046     stream << nodeInfo.vendorCode;
00047     stream << nodeInfo.serventVersion;
00048     stream << static_cast <uchar> (nodeInfo.type);
00049     stream << static_cast <uchar> (nodeInfo.ultrapeerNeeded);
00050     //stream << nodeInfo.pongCaching;
00051     //stream << nodeInfo.ggep;
00052     //stream << nodeInfo.queryRouting;
00053     //stream << nodeInfo.ultrapeerQueryRouting;
00054     //stream << nodeInfo.dynamicQuering;
00055     //stream << nodeInfo.guess;
00056     //stream << nodeInfo.vendorMessage;
00057     //stream << nodeInfo.extProbes;
00058     //stream << nodeInfo.encoding;
00059     stream << nodeInfo.freeUltrapeerSlots;
00060     stream << nodeInfo.freeLeafSlots;
00061     stream << nodeInfo.dailyUptime;
00062 
00063     return stream;
00064 }
00065 
00066 QDataStream & Gnutella::operator >> (QDataStream &stream, NodeInfo &nodeInfo)
00067 {
00068     uchar type = 0;
00069     uchar ultrapeerNeeded = true;
00070 
00071     stream >> nodeInfo.address;
00072     stream >> nodeInfo.identification;
00073     stream >> nodeInfo.vendorCode;
00074     stream >> nodeInfo.serventVersion;
00075     stream >> type;
00076     stream >> ultrapeerNeeded;
00077     //stream >> nodeInfo.pongCaching;
00078     //stream >> nodeInfo.ggep;
00079     //stream >> nodeInfo.queryRouting;
00080     //stream >> nodeInfo.ultrapeerQueryRouting;
00081     //stream >> nodeInfo.dynamicQuering;
00082     //stream >> nodeInfo.guess;
00083     //stream >> nodeInfo.vendorMessage;
00084     //stream >> nodeInfo.extProbes;
00085     //stream >> nodeInfo.encoding;
00086     stream >> nodeInfo.freeUltrapeerSlots;
00087     stream >> nodeInfo.freeLeafSlots;
00088     stream >> nodeInfo.dailyUptime;
00089 
00090     nodeInfo.type = static_cast <NodeType> (type);
00091     nodeInfo.ultrapeerNeeded = static_cast <bool> (ultrapeerNeeded);
00092 
00093     return stream;
00094 }