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