Classified ads
dbretrievalengine.h
Go to the documentation of this file.
1 /* -*-C++-*- -*-coding: utf-8-unix;-*-
2  Classified Ads is Copyright (c) Antti Järvinen 2013-2017.
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 DB_RECORD_RETRIEVAL_ENG_H
24 #define DB_RECORD_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 #include "../datamodel/cadbrecord.h"
32 
50 class DbRecordRetrievalEngine : public QTimer {
51  Q_OBJECT
52 public:
59  Model& aModel ) ;
68  void startRetrieving( CaDbRecord::SearchTerms aSearchTerms ) ;
69 
70 public slots:
77  void stopRetrieving( ) ;
78 
84  void notifyOfContentReceived(const Hash& aHashOfContent,
85  const ProtocolItemType aTypeOfReceivedContent );
86 
93  const Hash aHashOfAttemptedNode );
97  void run();
98 private: // methods
99  void sendQueryToNode(const CaDbRecord::SearchTerms& aSearchTerms,
100  const Hash& aNodeFingerPrint) ;
101 private: // data
104  bool iNowRunning ;
109  typedef struct DlQueueItemStruct {
113  QList<Hash> iListOfNodes ;
115  QDateTime iTimeOfLastRefresh ;
116  } DlQueueItem ;
123  QList<DlQueueItem> iSearchTerms ;
124 } ;
125 #endif
void notifyOfContentReceived(const Hash &aHashOfContent, const ProtocolItemType aTypeOfReceivedContent)
Class for keeping app state.
Definition: controller.h:83
QList< Hash > iNodeCandidatesToTryQuery
Definition: dbretrievalengine.h:105
void nodeConnectionAttemptStatus(Connection::ConnectionState aStatus, const Hash aHashOfAttemptedNode)
void sendQueryToNode(const CaDbRecord::SearchTerms &aSearchTerms, const Hash &aNodeFingerPrint)
bool iNowRunning
Definition: dbretrievalengine.h:104
Hash is class that carries 160-bit digest.
Definition: hash.h:38
QList< Hash > iNodesSuccessfullyConnected
Definition: dbretrievalengine.h:106
ConnectionState
Definition: connection.h:47
ProtocolItemType
Definition: protocol.h:157
void startRetrieving(CaDbRecord::SearchTerms aSearchTerms)
Definition: dbretrievalengine.h:109
Network-connection logic relating fetching db records from DHT.
Definition: dbretrievalengine.h:50
CaDbRecord::SearchTerms iTerms
Definition: dbretrievalengine.h:111
M of the MVC pattern. Handles permanent storage.
Definition: model.h:50
QDateTime iTimeOfLastRefresh
Definition: dbretrievalengine.h:115
Controller * iController
Definition: dbretrievalengine.h:102
DbRecordRetrievalEngine(Controller *aController, Model &aModel)
Model & iModel
Definition: dbretrievalengine.h:103
struct DbRecordRetrievalEngine::DlQueueItemStruct DlQueueItem
QList< Hash > iListOfNodes
Definition: dbretrievalengine.h:113
Definition: cadbrecord.h:40
QList< Hash > iNodesFailurefullyConnected
Definition: dbretrievalengine.h:107
QList< DlQueueItem > iSearchTerms
Definition: dbretrievalengine.h:123