libktorrent  2.2.0
getpeersrsp.h
1 /***************************************************************************
2  * Copyright (C) 2012 by *
3  * Joris Guisson <joris.guisson@gmail.com> *
4  * *
5  * This program is free software; you can redistribute it and/or modify *
6  * it under the terms of the GNU General Public License as published by *
7  * the Free Software Foundation; either version 2 of the License, or *
8  * (at your option) any later version. *
9  * *
10  * This program is distributed in the hope that it will be useful, *
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of *
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
13  * GNU General Public License for more details. *
14  * *
15  * You should have received a copy of the GNU General Public License *
16  * along with this program; if not, write to the *
17  * Free Software Foundation, Inc., *
18  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. *
19  ***************************************************************************/
20 
21 #ifndef DHT_GETPEERSRSP_H
22 #define DHT_GETPEERSRSP_H
23 
24 
25 #include "rpcmsg.h"
26 #include "packednodecontainer.h"
27 
28 namespace dht
29 {
30 
34  class KTORRENT_EXPORT GetPeersRsp : public RPCMsg, public PackedNodeContainer
35  {
36  public:
37  GetPeersRsp();
38  GetPeersRsp(const QByteArray & mtid, const Key & id, const QByteArray & token);
39  GetPeersRsp(const QByteArray & mtid, const Key & id, const DBItemList & values, const QByteArray & token);
40  ~GetPeersRsp() override;
41 
42  void apply(DHT* dh_table) override;
43  void print() override;
44  void encode(QByteArray & arr) const override;
45  void parse(bt::BDictNode* dict) override;
46 
47  const DBItemList & getItemList() const {return items;}
48  const QByteArray & getToken() const {return token;}
49  bool containsNodes() const {return nodes.size() > 0 || nodes6.size() > 0;}
50  bool containsValues() const {return nodes.size() == 0;}
51 
52  typedef QSharedPointer<GetPeersRsp> Ptr;
53  private:
54  QByteArray token;
55  DBItemList items;
56  };
57 
58 }
59 
60 #endif // DHT_GETPEERSRSP_H
bt::BDictNode
Represents a dictionary in bencoded data.
Definition: bnode.h:119