Classified ads
/tmp/classified_ads/controller.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 #ifndef CONTROLLER_H
21 #define CONTROLLER_H
22 #include <QtGui>
23 #include <QBoxLayout>
24 #include "mcontroller.h"
25 #include "net/protocol.h" // for ProtocolItemType
27 
28 class FrontWidget ;
29 class PublishingEngine ;
30 class RetrievalEngine ;
31 class QMainWindow ;
32 class QMenu ;
33 
42 class Controller : public MController {
43  Q_OBJECT
44 
45 public:
46 
50  Controller(QApplication& app) ;
54  ~Controller() ;
64  bool aIsBackgroundDl) ;
80  virtual void userInterfaceAction ( CAUserInterfaceRequest aRequest,
81  const Hash& aHashConcerned = KNullHash,
82  const Hash& aFetchFromNode = KNullHash) ;
86  virtual void hideUI() ;
90  virtual void showUI() ;
94  virtual void setProfileInUse(const Hash& aProfileHash) ;
98  virtual const Hash& profileInUse() ;
105  virtual void setContentKeyPasswd(QString aPasswd) ;
110  virtual QString contentKeyPasswd() const ;
111 
112 public: // methods
117  virtual Node& getNode() const ;
122  virtual NetworkListener *networkListener() const ;
126  virtual Model &model() const ;
127 signals:
128  void userProfileSelected(const Hash& aProfile) ;
130  void waitDialogToBeDismissed() ;
131 public slots:
132  virtual void exitApp() ;
133  virtual void displayAboutBox() ;
134  virtual void displayFront() ;
135  virtual void changeProfilePasswd() ;
136  virtual void createProfile() ;
137  virtual void deleteProfile() ;
138  virtual void selectProfile() ;
139  virtual void displaySettings() ;
140  virtual void displayStatus() ;
141  virtual void displaySearch() ;
148  virtual void handleError(MController::CAErrorSituation aError,
149  const QString& aExplanation) ;
157  void notifyOfContentReceived(const Hash& aHashOfContent,
158  const ProtocolItemType aTypeOfReceivedContent );
169  void notifyOfContentReceived(const Hash& aHashOfContent,
170  const Hash& aHashOfClassification,
171  const ProtocolItemType aTypeOfReceivedContent );
180  void notifyOfContentNotReceived(const Hash& aHashOfContent,
181  const ProtocolItemType aTypeOfNotReceivdContent );
182 
190  virtual void storePrivateDataOfSelectedProfile() ;
195  virtual void reStorePrivateDataOfSelectedProfile() ;
196 
201  virtual bool isContactInContactList(const Hash& aFingerPrint) const ;
208  virtual QString displayableNameForProfile(const Hash& aProfileFingerPrint) const ;
214  virtual void offerDisplayNameForProfile(const Hash& aProfileFingerPrint,
215  const QString& aDisplayName,
216  const bool iUpdatePersistenStorage=false) ;
234  void sendProfileUpdateQuery(const Hash& aProfileFingerPrint,
235  const Hash& aProfileNodeFingerPrint = KNullHash ) ;
236 private:
237  void createMenus();
238  int createPidFile();
239  void deletePidFile();
240 private:
241  QMainWindow* iWin ;
243  QApplication& iApp ;
244  QBoxLayout* iLayout ;
245  QMenu *iFileMenu;
246  QAction *iExitAct;
247  QAction *iAboutAct;
248  QAction *iPwdChangeAct;
259  QString iContentKeyPasswd ;
290  QMap<Hash,QString> iHashDisplaynameMapping ;
291 } ;
292 #endif
293 
virtual void selectProfile()
Definition: FrontWidget.h:41
virtual void showUI()
Controller(QApplication &app)
QAction * iProfileCreateAct
Definition: controller.h:250
Class for keeping app state.
Definition: controller.h:42
virtual void createProfile()
virtual void displayFront()
virtual void userInterfaceAction(CAUserInterfaceRequest aRequest, const Hash &aHashConcerned=KNullHash, const Hash &aFetchFromNode=KNullHash)
Node is a peer in network.
Definition: node.h:39
FrontWidget * iCurrentWidget
Definition: controller.h:242
NetworkListener * iListener
Definition: controller.h:257
int createPidFile()
QMainWindow * iWin
Definition: controller.h:241
virtual Node & getNode() const
QApplication & iApp
Definition: controller.h:243
Hash iHashOfObjectBeingWaitedFor
Definition: controller.h:273
virtual void startRetrievingContent(NetworkRequestExecutor::NetworkRequestQueueItem aReq, bool aIsBackgroundDl)
virtual void offerDisplayNameForProfile(const Hash &aProfileFingerPrint, const QString &aDisplayName, const bool iUpdatePersistenStorage=false)
void notifyOfContentNotReceived(const Hash &aHashOfContent, const ProtocolItemType aTypeOfNotReceivdContent)
Network-connection logic relating fetching items from DHT.
Definition: retrievalengine.h:39
virtual QString contentKeyPasswd() const
virtual void displaySearch()
virtual void storePrivateDataOfSelectedProfile()
virtual void handleError(MController::CAErrorSituation aError, const QString &aExplanation)
CAUserInterfaceRequest
Definition: mcontroller.h:61
virtual Model & model() const
QAction * iExitAct
Definition: controller.h:246
virtual NetworkListener * networkListener() const
Hash is class that carries 160-bit digest.
Definition: hash.h:37
CAErrorSituation
Definition: mcontroller.h:48
virtual void displaySettings()
virtual bool isContactInContactList(const Hash &aFingerPrint) const
QAction * iAboutAct
Definition: controller.h:247
Hash iNodeForCommentBeingWaitedFor
Definition: controller.h:286
ProtocolItemType
Definition: protocol.h:124
Hash iProfileHash
Definition: controller.h:260
QString iContentKeyPasswd
Definition: controller.h:259
void userProfileSelected(const Hash &aProfile)
virtual void exitApp()
virtual void setContentKeyPasswd(QString aPasswd)
QAction * iDisplaySettingsAct
Definition: controller.h:252
virtual const Hash & profileInUse()
class for listening to incoming network connections.
Definition: networklistener.h:40
Pure-virtual interface class for controller. This is spammed across parties needing access to applica...
Definition: mcontroller.h:39
QAction * iProfileSelectAct
Definition: controller.h:251
QMenu * iFileMenu
Definition: controller.h:245
void deletePidFile()
Hash KNullHash
QAction * iProfileDeleteAct
Definition: controller.h:249
M of the MVC pattern. Handles permanent storage.
Definition: model.h:47
void sendProfileUpdateQuery(const Hash &aProfileFingerPrint, const Hash &aProfileNodeFingerPrint=KNullHash)
virtual void hideUI()
QBoxLayout * iLayout
Definition: controller.h:244
Node * iNode
Definition: controller.h:255
Class that will initiate 1 or more network connections.
Definition: networkconnectorengine.h:44
virtual void displayAboutBox()
virtual void deleteProfile()
virtual QString displayableNameForProfile(const Hash &aProfileFingerPrint) const
QAction * iDisplaySearchAct
Definition: controller.h:254
Hash iHashOfProfileCommentBeingWaitedFor
Definition: controller.h:281
void waitDialogToBeDismissed()
Work queue item.
Definition: netrequestexecutor.h:59
RetrievalEngine * iRetrievalEngine
Definition: controller.h:262
virtual void changeProfilePasswd()
virtual void displayStatus()
QAction * iDisplayStatusAct
Definition: controller.h:253
Network-connection logic relating content publish demands.
Definition: publishingengine.h:40
PublishingEngine * iPubEngine
Definition: controller.h:261
void notifyOfContentReceived(const Hash &aHashOfContent, const ProtocolItemType aTypeOfReceivedContent)
virtual void setProfileInUse(const Hash &aProfileHash)
QMap< Hash, QString > iHashDisplaynameMapping
Definition: controller.h:290
QAction * iPwdChangeAct
Definition: controller.h:248
virtual void reStorePrivateDataOfSelectedProfile()
NetworkConnectorEngine * iNetEngine
Definition: controller.h:258
Model * iModel
Definition: controller.h:256
void createMenus()
ProtocolItemType iTypeOfObjectBeingWaitedFor
Definition: controller.h:269