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
7  modify it under the terms of the GNU Lesser General Public
8  License as published by the Free Software Foundation; either
9  version 2.1 of the License, or (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 GNU
14  Lesser General Public License for more details.
15 
16  You should have received a copy of the GNU Lesser General Public
17  License along with Classified Ads; if not, write to the Free Software
18  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
19 */
20 
21 #ifndef M_NODEMODEL_PROTOCOL_INTERFACE_H
22 #define M_NODEMODEL_PROTOCOL_INTERFACE_H
23 #include <QPair>
24 class Connection ;
25 class QHostAddress ;
26 class Node ;
27 class QSslKey ;
28 class QSslCertificate ;
29 class Hash ;
30 
31 
40 public:
47  QHostAddress iAddress ;
48  int iPort ;
50  bool operator==(const struct HostConnectQueueItemStructure& a) const ;
52  virtual bool nodeGreetingReceived(Node& aNode ,
53  bool aWasInitialGreeting = false ) = 0 ;
54  virtual Hash& nodeFingerPrint() = 0 ;
55  virtual int listenPortOfThisNode() = 0 ;
57  virtual void setListenPortOfThisNode(int port) = 0 ;
58  virtual const QSslCertificate& nodeCert() const = 0 ;
60  virtual const QSslKey& nodeKey() const = 0 ;
61  virtual QByteArray* getNextItemToSend(Connection& aConnection) = 0 ;
62  virtual Node* nodeByHash(const Hash& aHash) = 0 ;
63  virtual QList<Node *>* getNodesBeforeHash(const Hash& aHash,
64  unsigned aMaxNodes) = 0 ;
65  virtual void closeOldestInactiveConnection() = 0 ;
66  virtual QList<Node *>* getNodesAfterHash(const Hash& aHash,
67  unsigned aMaxNodes,
68  int aMaxInactivityMinutes = -1 ) = 0 ;
69  virtual QList<HostConnectQueueItem> getHotAddresses() = 0 ;
70  virtual bool updateNodeLastConnectTimeInDb(Node& aNode) =0 ;
71  virtual QList<Node *>* getHotNodes(int aMaxNodes) = 0 ;
83  virtual void addNodeFromBroadcast(const Hash& aNodeFingerPrint,
84  const QHostAddress& aAddr,
85  int aPort ) = 0 ;
93  virtual bool addNodeToConnectionWishList(Node* aNode) = 0 ;
94 
100  virtual bool addNodeToConnectionWishList(const Hash& aNode) = 0 ;
101 
107  virtual Node* nextConnectionWishListItem() = 0 ;
111  virtual bool isNodeAlreadyConnected(const Node& aNode) const = 0 ;
116  virtual bool isNodeAlreadyConnected(const Hash& aHash) const = 0 ;
138  virtual Hash bucketEndHash(const Hash& aFingerPrintOfNodeAsking) = 0 ;
143  virtual bool updateNodeLastMutualConnectTimeInDb(const Hash& aNodeFp,
144  quint32 aTime ) = 0 ;
146  virtual void setDnsName(QString aName) = 0 ;
148  virtual QString getDnsName() = 0 ;
152  virtual void offerNodeToRecentlyFailedList(const Hash& aFailedNodeHash) = 0 ;
153 };
154 #endif
virtual void offerNodeToRecentlyFailedList(const Hash &aFailedNodeHash)=0
virtual QList< HostConnectQueueItem > getHotAddresses()=0
Hash iNodeHash
Definition: mnodemodelprotocolinterface.h:49
Node is a peer in network.
Definition: node.h:40
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
int iPort
Definition: mnodemodelprotocolinterface.h:48
virtual const QSslCertificate & nodeCert() const =0
Definition: mnodemodelprotocolinterface.h:46
virtual Node * nodeByHash(const Hash &aHash)=0
bool operator==(const struct HostConnectQueueItemStructure &a) const
Hash is class that carries 160-bit digest.
Definition: hash.h:38
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
struct MNodeModelProtocolInterface::HostConnectQueueItemStructure HostConnectQueueItem
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 closeOldestInactiveConnection()=0
QHostAddress iAddress
Definition: mnodemodelprotocolinterface.h:47
virtual Hash bucketEndHash(const Hash &aFingerPrintOfNodeAsking)=0
virtual bool isNodeAlreadyConnected(const Node &aNode) const =0
Pure-virtual interface of nodemodel.
Definition: mnodemodelprotocolinterface.h:39
virtual QList< Node * > * getHotNodes(int aMaxNodes)=0
Class that represents a network connection.
Definition: connection.h:43
virtual bool addNodeToConnectionWishList(Node *aNode)=0
virtual void setListenPortOfThisNode(int port)=0