Classified ads
networkconnectorengine.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 
21 
22 #ifndef NETWORK_CONNECTOR_ENG_H
23 #define NETWORK_CONNECTOR_ENG_H
24 
25 #include <QTcpSocket>
26 #include <QUdpSocket>
27 #include <QHostAddress>
28 #include <QPair>
29 #include "connection.h" // for ConnectionObserver
30 #include "../controller.h"
31 #include "../datamodel/model.h"
32 
34 
44 class NetworkConnectorEngine : public QThread {
45  Q_OBJECT
46 public:
51  Model *aModel,
52  Connection::ConnectionObserver &aObserver) ;
67  void run();
68 public slots:
69  void threadIsDeleted() ;
70  void blackListNetworkAddr(QHostAddress aAddr) ;
72  const Hash aHashOfAttemptedNode );
73 signals:
74  void error(QTcpSocket::SocketError socketError);
75 private:
77  void spawnNewConnection(const QHostAddress& aAddr,
78  const int aPort,
79  const Hash& aHashOfNodeToConnect) ;
88  bool pruneConnectionProspectList(QList<Node *>* aListToPrune) const ;
93  void sendBroadCast() ;
98  bool tryServeWishListItem() ;
122  void sendPrivateMessagesPoll(const Hash& aNodeFingerPrint) ;
123 private: // methods:
124  bool performDNSLookup(QHostAddress* aAddressToBeSet,
125  const QString& aFromDnsName,
126  bool aDoWeHaveIpv6) ;
127 public:
128  bool iNeedsToRun ;
129 private: // data
133  QList<QPair<QHostAddress,int> > iAddressesInOrderToConnect ;
134  QUdpSocket* iBroadCastSocket ;
155  QList<QHostAddress> iAddressBlacklist ;
158 } ;
159 #endif
Class containing routines for parsing protocol messages. Methods are mainly called from network conne...
Definition: protocol_message_parser.h:39
void spawnNewConnection(const QHostAddress &aAddr, const int aPort, const Hash &aHashOfNodeToConnect)
void nodeConnectionAttemptStatus(Connection::ConnectionState aStatus, const Hash aHashOfAttemptedNode)
Class for keeping app state.
Definition: controller.h:42
quint32 iTimeOfLastMsgPollForProfile
Definition: networkconnectorengine.h:148
time_t iTimeOfLastMsgPoll
Definition: networkconnectorengine.h:141
QUdpSocket * iBroadCastSocket
Definition: networkconnectorengine.h:134
QList< QHostAddress > iAddressBlacklist
Definition: networkconnectorengine.h:155
Hash is class that carries 160-bit digest.
Definition: hash.h:37
void error(QTcpSocket::SocketError socketError)
void createConnectionsToNodesStoringPrivateMessages()
Model * iModel
Definition: networkconnectorengine.h:131
Controller * iController
Definition: networkconnectorengine.h:130
NetworkConnectorEngine(Controller *aController, Model *aModel, Connection::ConnectionObserver &aObserver)
bool iNeedsToRun
Definition: networkconnectorengine.h:128
QList< QPair< QHostAddress, int > > iAddressesInOrderToConnect
Definition: networkconnectorengine.h:133
ConnectionState
Definition: connection.h:45
void blackListNetworkAddr(QHostAddress aAddr)
M of the MVC pattern. Handles permanent storage.
Definition: model.h:47
Interface for receiving network traffic.
Definition: connection.h:57
Class that will initiate 1 or more network connections.
Definition: networkconnectorengine.h:44
bool pruneConnectionProspectList(QList< Node * > *aListToPrune) const
Connection::ConnectionObserver & iConnectionObserver
Definition: networkconnectorengine.h:132
time_t iTimeOfLastBroadCast
Definition: networkconnectorengine.h:135
bool performDNSLookup(QHostAddress *aAddressToBeSet, const QString &aFromDnsName, bool aDoWeHaveIpv6)
Hash iProfileToPollPrivateMessages
Definition: networkconnectorengine.h:156
QList< Hash > iPrivateMessagePollWishList
Definition: networkconnectorengine.h:157
void sendPrivateMessagesPoll(const Hash &aNodeFingerPrint)