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