Classified ads
mockup_nodemodel.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 MOCKUP_NODEMODEL_H
21 #define MOCKUP_NODEMODEL_H
22 #include "../mcontroller.h"
23 #include "../net/node.h"
24 #include "../datamodel/mmodelprotocolinterface.h"
25 #include "../datamodel/mnodemodelprotocolinterface.h"
26 #include <QMutex>
27 
31 class MockUpNodeModel : public QObject, public MNodeModelProtocolInterface
32 {
33  Q_OBJECT
34 
35 public:
39  MockUpNodeModel(MController *aMController) ;
44  virtual bool nodeGreetingReceived(Node& aNode ,
45  bool aWasInitialGreeting = false ) ;
46  virtual Hash& nodeFingerPrint() ;
47  virtual int listenPortOfThisNode() ;
48  virtual const QSslCertificate& nodeCert() const ;
50  virtual const QSslKey& nodeKey() const ;
51  virtual QByteArray* getNextItemToSend(Connection& aConnection) ;
52  virtual Node* nodeByHash(const Hash& aHash) ;
53  virtual QList<Node *>* getNodesBeforeHash(const Hash& aHash,
54  int aMaxNodes) ;
55  virtual void closeOldestInactiveConnection() ;
56  virtual QList<Node *>* getNodesAfterHash(const Hash& aHash,
57  int aMaxNodes,
58  int aMaxInactivityMinutes = -1 ) ;
59  virtual QList<QPair<QHostAddress,int> > getHotAddresses() ;
60  virtual bool updateNodeLastConnectTimeInDb(Node& aNode) ;
61  virtual QList<Node *>* getHotNodes(int aMaxNodes) ;
62 
74  virtual void addNodeFromBroadcast(const Hash& aNodeFingerPrint,
75  const QHostAddress& aAddr,
76  int aPort ) ;
83  virtual void addNodeToConnectionWishList(Node* aNode) ;
84 
89  virtual bool addNodeToConnectionWishList(const Hash& aNode) ;
90 
96  virtual Node* nextConnectionWishListItem() ;
100  virtual bool isNodeAlreadyConnected(const Node& aNode) const ;
105  virtual bool isNodeAlreadyConnected(const Hash& aHash) const ;
106 
107  virtual Hash bucketEndHash(const Hash& aFingerPrintOfNodeAsking) ;
112  virtual bool updateNodeLastMutualConnectTimeInDb(const Hash& aNodeFp,
113  quint32 aTime ) ;
114  virtual void setListenPortOfThisNode(int port) ;
115  virtual QList<Node*>* getNodesBeforeHash(const Hash& h, unsigned int i);
116  virtual QList<Node*>* getNodesAfterHash(const Hash& h, unsigned int u, int i) ;
117  virtual void setDnsName(QString aName) ;
118  virtual QString getDnsName() ;
119 
120 public:
122 private:
125  QString iDnsName ;
126 } ;
127 #endif
virtual Node * nextConnectionWishListItem()
virtual QString getDnsName()
virtual bool nodeGreetingReceived(Node &aNode, bool aWasInitialGreeting=false)
virtual void closeOldestInactiveConnection()
Node is a peer in network.
Definition: node.h:39
Hash * iFingerPrintOfThisNode
Definition: mockup_nodemodel.h:124
virtual QList< QPair< QHostAddress, int > > getHotAddresses()
virtual QList< Node * > * getNodesAfterHash(const Hash &aHash, int aMaxNodes, int aMaxInactivityMinutes=-1)
virtual const QSslKey & nodeKey() const
virtual bool updateNodeLastConnectTimeInDb(Node &aNode)
MockUpNodeModel(MController *aMController)
Hash is class that carries 160-bit digest.
Definition: hash.h:37
virtual bool updateNodeLastMutualConnectTimeInDb(const Hash &aNodeFp, quint32 aTime)
virtual QByteArray * getNextItemToSend(Connection &aConnection)
Node * iLastNodeReceived
Definition: mockup_nodemodel.h:121
Pure-virtual interface class for controller. This is spammed across parties needing access to applica...
Definition: mcontroller.h:39
virtual bool isNodeAlreadyConnected(const Node &aNode) const
virtual void setDnsName(QString aName)
virtual void addNodeFromBroadcast(const Hash &aNodeFingerPrint, const QHostAddress &aAddr, int aPort)
virtual int listenPortOfThisNode()
virtual Node * nodeByHash(const Hash &aHash)
virtual Hash bucketEndHash(const Hash &aFingerPrintOfNodeAsking)
virtual QList< Node * > * getNodesBeforeHash(const Hash &aHash, int aMaxNodes)
virtual QList< Node * > * getHotNodes(int aMaxNodes)
virtual const QSslCertificate & nodeCert() const
virtual void addNodeToConnectionWishList(Node *aNode)
virtual Hash & nodeFingerPrint()
QString iDnsName
Definition: mockup_nodemodel.h:125
Pure-virtual interface of nodemodel.
Definition: mnodemodelprotocolinterface.h:38
MController * iController
Definition: mockup_nodemodel.h:123
Class that represents a network connection.
Definition: connection.h:41
virtual void setListenPortOfThisNode(int port)
not a real part datamodel. debugging aid.
Definition: mockup_nodemodel.h:31