Classified ads
mnodemodelprotocolinterface.h
Go to the documentation of this file.
1 /* -*-C++-*- -*-coding: utf-8-unix;-*-
2  Classified Ads is Copyright (c) Antti Järvinen 2013.
3 
4  This file is part of Classified Ads.
5 
6  Classified Ads is free software: you can redistribute it and/or modify
7  it under the terms of the GNU General Public License as published by
8  the Free Software Foundation, either version 3 of the License, or
9  (at your option) any later version.
10 
11  Classified Ads is distributed in the hope that it will be useful,
12  but WITHOUT ANY WARRANTY; without even the implied warranty of
13  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  GNU General Public License for more details.
15 
16  You should have received a copy of the GNU General Public License
17  along with Classified Ads. If not, see <http://www.gnu.org/licenses/>.
18 */
19 
20 #ifndef M_NODEMODEL_PROTOCOL_INTERFACE_H
21 #define M_NODEMODEL_PROTOCOL_INTERFACE_H
22 #include <QPair>
23 class Connection ;
24 class QHostAddress ;
25 class Node ;
26 class QSslKey ;
27 class QSslCertificate ;
28 class Hash ;
29 
30 
39 public:
40  virtual bool nodeGreetingReceived(Node& aNode ,
41  bool aWasInitialGreeting = false ) = 0 ;
42  virtual Hash& nodeFingerPrint() = 0 ;
43  virtual int listenPortOfThisNode() = 0 ;
45  virtual void setListenPortOfThisNode(int port) = 0 ;
46  virtual const QSslCertificate& nodeCert() const = 0 ;
48  virtual const QSslKey& nodeKey() const = 0 ;
49  virtual QByteArray* getNextItemToSend(Connection& aConnection) = 0 ;
50  virtual Node* nodeByHash(const Hash& aHash) = 0 ;
51  virtual QList<Node *>* getNodesBeforeHash(const Hash& aHash,
52  unsigned aMaxNodes) = 0 ;
53  virtual void closeOldestInactiveConnection() = 0 ;
54  virtual QList<Node *>* getNodesAfterHash(const Hash& aHash,
55  unsigned aMaxNodes,
56  int aMaxInactivityMinutes = -1 ) = 0 ;
57  virtual QList<QPair<QHostAddress,int> > getHotAddresses() = 0 ;
58  virtual bool updateNodeLastConnectTimeInDb(Node& aNode) =0 ;
59  virtual QList<Node *>* getHotNodes(int aMaxNodes) = 0 ;
71  virtual void addNodeFromBroadcast(const Hash& aNodeFingerPrint,
72  const QHostAddress& aAddr,
73  int aPort ) = 0 ;
80  virtual void addNodeToConnectionWishList(Node* aNode) = 0 ;
81 
86  virtual bool addNodeToConnectionWishList(const Hash& aNode) = 0 ;
87 
93  virtual Node* nextConnectionWishListItem() = 0 ;
97  virtual bool isNodeAlreadyConnected(const Node& aNode) const = 0 ;
102  virtual bool isNodeAlreadyConnected(const Hash& aHash) const = 0 ;
124  virtual Hash bucketEndHash(const Hash& aFingerPrintOfNodeAsking) = 0 ;
129  virtual bool updateNodeLastMutualConnectTimeInDb(const Hash& aNodeFp,
130  quint32 aTime ) = 0 ;
132  virtual void setDnsName(QString aName) = 0 ;
134  virtual QString getDnsName() = 0 ;
135 };
136 #endif
Node is a peer in network.
Definition: node.h:39
virtual QByteArray * getNextItemToSend(Connection &aConnection)=0
virtual void addNodeFromBroadcast(const Hash &aNodeFingerPrint, const QHostAddress &aAddr, int aPort)=0
virtual QList< Node * > * getNodesBeforeHash(const Hash &aHash, unsigned aMaxNodes)=0
virtual const QSslCertificate & nodeCert() const =0
virtual Node * nodeByHash(const Hash &aHash)=0
Hash is class that carries 160-bit digest.
Definition: hash.h:37
virtual bool updateNodeLastMutualConnectTimeInDb(const Hash &aNodeFp, quint32 aTime)=0
virtual QList< Node * > * getNodesAfterHash(const Hash &aHash, unsigned aMaxNodes, int aMaxInactivityMinutes=-1)=0
virtual int listenPortOfThisNode()=0
virtual QString getDnsName()=0
virtual const QSslKey & nodeKey() const =0
virtual Hash & nodeFingerPrint()=0
virtual Node * nextConnectionWishListItem()=0
virtual bool updateNodeLastConnectTimeInDb(Node &aNode)=0
virtual bool nodeGreetingReceived(Node &aNode, bool aWasInitialGreeting=false)=0
virtual void setDnsName(QString aName)=0
virtual void addNodeToConnectionWishList(Node *aNode)=0
virtual void closeOldestInactiveConnection()=0
virtual Hash bucketEndHash(const Hash &aFingerPrintOfNodeAsking)=0
virtual bool isNodeAlreadyConnected(const Node &aNode) const =0
Pure-virtual interface of nodemodel.
Definition: mnodemodelprotocolinterface.h:38
virtual QList< Node * > * getHotNodes(int aMaxNodes)=0
Class that represents a network connection.
Definition: connection.h:41
virtual void setListenPortOfThisNode(int port)=0
virtual QList< QPair< QHostAddress, int > > getHotAddresses()=0