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
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 MOCKUP_NODEMODEL_H
22 #define MOCKUP_NODEMODEL_H
23 #include "../mcontroller.h"
24 #include "../net/node.h"
25 #include "../datamodel/mmodelprotocolinterface.h"
26 #include "../datamodel/mnodemodelprotocolinterface.h"
27 #include <QMutex>
28 
32 class MockUpNodeModel : public QObject, public MNodeModelProtocolInterface {
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<HostConnectQueueItem> 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 bool 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() ;
122  virtual void offerNodeToRecentlyFailedList(const Hash& aFailedNodeHash) ;
123 public:
125 private:
128  QString iDnsName ;
129 } ;
130 #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:40
virtual void offerNodeToRecentlyFailedList(const Hash &aFailedNodeHash)
Hash * iFingerPrintOfThisNode
Definition: mockup_nodemodel.h:127
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:38
virtual bool updateNodeLastMutualConnectTimeInDb(const Hash &aNodeFp, quint32 aTime)
virtual QList< HostConnectQueueItem > getHotAddresses()
virtual bool addNodeToConnectionWishList(Node *aNode)
virtual QByteArray * getNextItemToSend(Connection &aConnection)
Node * iLastNodeReceived
Definition: mockup_nodemodel.h:124
Pure-virtual interface class for controller. This is spammed across parties needing access to applica...
Definition: mcontroller.h:43
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 Hash & nodeFingerPrint()
QString iDnsName
Definition: mockup_nodemodel.h:128
Pure-virtual interface of nodemodel.
Definition: mnodemodelprotocolinterface.h:39
MController * iController
Definition: mockup_nodemodel.h:126
Class that represents a network connection.
Definition: connection.h:43
virtual void setListenPortOfThisNode(int port)
not a real part datamodel. debugging aid.
Definition: mockup_nodemodel.h:32