Classified ads
retrievalengine.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 RETRIEVAL_ENG_H
24 #define RETRIEVAL_ENG_H
25 
26 #include <QHostAddress>
27 #include <QPair>
28 #include "connection.h" // for ConnectionObserver
29 #include "../controller.h"
30 #include "../datamodel/model.h"
31 
40 class RetrievalEngine : public QTimer {
41  Q_OBJECT
42 public:
48  RetrievalEngine(Controller* aController,
49  Model& aModel ) ;
62  bool aIsPriorityWork) ;
68  void notifyOfContentReceived(const Hash& aHashOfContent,
69  const ProtocolItemType aTypeOfReceivdContent );
70 signals:
71  void error(QTcpSocket::SocketError socketError);
72  void notifyOfContentNotReceived(const Hash& aHashOfContent,
73  const ProtocolItemType aTypeOfNotReceivdContent );
74 public slots:
81  const Hash aHashOfAttemptedNode );
85  void run();
86 private:
87  void emptyNodeCandidateList() ;
90  void sendQueryToNode(const Hash& aNode) ;
93 public:
95  bool iNeedsToRun ;
96 private: // data
109  bool iNowRunning ;
111  QList<NetworkRequestExecutor::NetworkRequestQueueItem> iDownloadQueue ;
112 } ;
113 #endif
void askConnectionsForNodesOnConnectList()
Class for keeping app state.
Definition: controller.h:76
void nodeConnectionAttemptStatus(Connection::ConnectionState aStatus, const Hash aHashOfAttemptedNode)
QList< Hash > iNodeCandidatesToTryQuery
Definition: retrievalengine.h:106
void checkForUnSuccessfullyConnectedNodes()
Network-connection logic relating fetching items from DHT.
Definition: retrievalengine.h:40
QList< Hash > iNodesSuccessfullyConnected
Definition: retrievalengine.h:107
bool iNeedsToRun
Definition: retrievalengine.h:95
Hash is class that carries 160-bit digest.
Definition: hash.h:38
QList< NetworkRequestExecutor::NetworkRequestQueueItem > iDownloadQueue
Definition: retrievalengine.h:111
ConnectionState
Definition: connection.h:47
ProtocolItemType
Definition: protocol.h:150
void error(QTcpSocket::SocketError socketError)
NetworkRequestExecutor::NetworkRequestQueueItem iObjectBeingRetrieved
Definition: retrievalengine.h:104
void sendQueryToNode(const Hash &aNode)
Model & iModel
Definition: retrievalengine.h:98
void checkForSuccessfullyConnectedNodes()
bool iNowRunning
Definition: retrievalengine.h:109
M of the MVC pattern. Handles permanent storage.
Definition: model.h:48
void emptyNodeCandidateList()
void notifyOfContentNotReceived(const Hash &aHashOfContent, const ProtocolItemType aTypeOfNotReceivdContent)
void startRetrieving(NetworkRequestExecutor::NetworkRequestQueueItem aObject, bool aIsPriorityWork)
Work queue item.
Definition: netrequestexecutor.h:60
RetrievalEngine(Controller *aController, Model &aModel)
void notifyOfContentReceived(const Hash &aHashOfContent, const ProtocolItemType aTypeOfReceivdContent)
Controller * iController
Definition: retrievalengine.h:97
void sendQueryItemToAlreadyConnectedNodes()
QList< Hash > iNodesFailurefullyConnected
Definition: retrievalengine.h:108