libktorrent  2.2.0
rpcmsgfactory.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_RPCMSGFACTORY_H
22 #define DHT_RPCMSGFACTORY_H
23 
24 #include <ktorrent_export.h>
25 #include "rpcmsg.h"
26 
27 namespace dht
28 {
32  class RPCMethodResolver
33  {
34  public:
35  virtual ~RPCMethodResolver() {}
36 
38  virtual Method findMethod(const QByteArray & mtid) = 0;
39  };
40 
44  class KTORRENT_EXPORT RPCMsgFactory
45  {
46  public:
47  RPCMsgFactory();
48  virtual ~RPCMsgFactory();
49 
57  RPCMsg::Ptr build(bt::BDictNode* dict, RPCMethodResolver* method_resolver);
58 
59  private:
60  RPCMsg::Ptr buildRequest(bt::BDictNode* dict);
61  RPCMsg::Ptr buildResponse(bt::BDictNode* dict, RPCMethodResolver* method_resolver);
62  };
63 
64 }
65 
66 #endif // DHT_RPCMSGFACTORY_H
bt::BDictNode
Represents a dictionary in bencoded data.
Definition: bnode.h:119
dht::RPCMethodResolver::findMethod
virtual Method findMethod(const QByteArray &mtid)=0
Return the method associated with an mtid.