Classified ads
/tmp/classified-ads/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
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 
53 #ifndef CONTROLLER_H
54 #define CONTROLLER_H
55 #include <QtGui>
56 #include <QBoxLayout>
57 #include "mcontroller.h"
58 #include "net/protocol.h" // for ProtocolItemType
60 
61 class FrontWidget ;
62 class PublishingEngine ;
63 class RetrievalEngine ;
64 class QMainWindow ;
65 class QMenu ;
66 class VoiceCallEngine ;
67 
76 class Controller : public MController {
77  Q_OBJECT
78 
79 public:
80 
84  Controller(QApplication& app) ;
88  ~Controller() ;
98  bool aIsBackgroundDl,
99  ProtocolItemType aTypeOfExpectedObject) ;
116  virtual void userInterfaceAction ( CAUserInterfaceRequest aRequest,
117  const Hash& aHashConcerned = KNullHash,
118  const Hash& aFetchFromNode = KNullHash,
119  const QString* aAdditionalInformation = NULL) ;
123  virtual void hideUI() ;
127  virtual void showUI() ;
131  virtual void setProfileInUse(const Hash& aProfileHash) ;
135  virtual const Hash& profileInUse() ;
142  virtual void setContentKeyPasswd(QString aPasswd) ;
147  virtual QString contentKeyPasswd() const ;
148 
149 public: // methods
154  virtual Node& getNode() const ;
159  virtual NetworkListener *networkListener() const ;
163  virtual Model &model() const ;
164 signals:
165  void userProfileSelected(const Hash& aProfile) ;
167  void waitDialogToBeDismissed() ;
168 public slots:
169  virtual void exitApp() ;
170  virtual void displayAboutBox() ;
171  virtual void displayFront() ;
172  virtual void changeProfilePasswd() ;
173  virtual void createProfile() ;
174  virtual void deleteProfile() ;
175  virtual void selectProfile() ;
176  virtual void displaySettings() ;
177  virtual void displayStatus() ;
178  virtual void displaySearch() ;
185  virtual void handleError(MController::CAErrorSituation aError,
186  const QString& aExplanation) ;
194  void notifyOfContentReceived(const Hash& aHashOfContent,
195  const ProtocolItemType aTypeOfReceivedContent );
206  void notifyOfContentReceived(const Hash& aHashOfContent,
207  const Hash& aHashOfClassification,
208  const ProtocolItemType aTypeOfReceivedContent );
217  void notifyOfContentNotReceived(const Hash& aHashOfContent,
218  const ProtocolItemType aTypeOfNotReceivdContent );
219 
231  virtual void storePrivateDataOfSelectedProfile(bool aPublishTrustListToo = false) ;
236  virtual void reStorePrivateDataOfSelectedProfile() ;
237 
242  virtual bool isContactInContactList(const Hash& aFingerPrint) const ;
249  virtual QString displayableNameForProfile(const Hash& aProfileFingerPrint) const ;
255  virtual void offerDisplayNameForProfile(const Hash& aProfileFingerPrint,
256  const QString& aDisplayName,
257  const bool iUpdatePersistenStorage=false) ;
261  virtual void displayFileInfoOnUi(const BinaryFile& aFileMetadata) ;
267  virtual VoiceCallEngine* voiceCallEngine() ;
291  void sendProfileUpdateQuery(const Hash& aProfileFingerPrint,
292  const Hash& aProfileNodeFingerPrint = KNullHash ) ;
293 private:
294  void createMenus();
295  int createPidFile();
296  void deletePidFile();
297 private:
298  QMainWindow* iWin ;
300  QApplication& iApp ;
301  QBoxLayout* iLayout ;
302  QMenu *iFileMenu;
303  QAction *iExitAct;
304  QAction *iAboutAct;
305  QAction *iPwdChangeAct;
316  QString iContentKeyPasswd ;
347  QMap<Hash,QString> iHashDisplaynameMapping ;
356 } ;
357 #endif
358 
virtual void selectProfile()
virtual void startRetrievingContent(NetworkRequestExecutor::NetworkRequestQueueItem aReq, bool aIsBackgroundDl, ProtocolItemType aTypeOfExpectedObject)
Definition: FrontWidget.h:43
virtual void showUI()
Controller(QApplication &app)
QAction * iProfileCreateAct
Definition: controller.h:307
Class for keeping app state.
Definition: controller.h:76
virtual void createProfile()
Pure-virtual interface for voice call engine.
Definition: mvoicecallengine.h:33
virtual void displayFront()
Node is a peer in network.
Definition: node.h:40
FrontWidget * iCurrentWidget
Definition: controller.h:299
NetworkListener * iListener
Definition: controller.h:314
int createPidFile()
QMainWindow * iWin
Definition: controller.h:298
virtual Node & getNode() const
QApplication & iApp
Definition: controller.h:300
Hash iHashOfObjectBeingWaitedFor
Definition: controller.h:330
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:40
virtual QString contentKeyPasswd() const
virtual void displaySearch()
bool iInsideDestructor
Definition: controller.h:355
virtual void displayFileInfoOnUi(const BinaryFile &aFileMetadata)
virtual void handleError(MController::CAErrorSituation aError, const QString &aExplanation)
CAUserInterfaceRequest
Definition: mcontroller.h:65
virtual Model & model() const
QAction * iExitAct
Definition: controller.h:303
virtual NetworkListener * networkListener() const
Hash is class that carries 160-bit digest.
Definition: hash.h:38
CAErrorSituation
Definition: mcontroller.h:52
virtual void displaySettings()
virtual bool isContactInContactList(const Hash &aFingerPrint) const
QAction * iAboutAct
Definition: controller.h:304
Hash iNodeForCommentBeingWaitedFor
Definition: controller.h:343
ProtocolItemType
Definition: protocol.h:150
Carrier-class for binary blob.
Definition: binaryfile.h:37
Hash iProfileHash
Definition: controller.h:317
QString iContentKeyPasswd
Definition: controller.h:316
void userProfileSelected(const Hash &aProfile)
virtual void exitApp()
virtual void setContentKeyPasswd(QString aPasswd)
QAction * iDisplaySettingsAct
Definition: controller.h:309
virtual const Hash & profileInUse()
VoiceCallEngine * iVoiceCallEngine
Definition: controller.h:351
class for listening to incoming network connections.
Definition: networklistener.h:42
Pure-virtual interface class for controller. This is spammed across parties needing access to applica...
Definition: mcontroller.h:43
QAction * iProfileSelectAct
Definition: controller.h:308
QMenu * iFileMenu
Definition: controller.h:302
void deletePidFile()
Hash KNullHash
QAction * iProfileDeleteAct
Definition: controller.h:306
virtual void storePrivateDataOfSelectedProfile(bool aPublishTrustListToo=false)
M of the MVC pattern. Handles permanent storage.
Definition: model.h:48
virtual void userInterfaceAction(CAUserInterfaceRequest aRequest, const Hash &aHashConcerned=KNullHash, const Hash &aFetchFromNode=KNullHash, const QString *aAdditionalInformation=NULL)
void sendProfileUpdateQuery(const Hash &aProfileFingerPrint, const Hash &aProfileNodeFingerPrint=KNullHash)
virtual VoiceCallEngine * voiceCallEngine()
virtual void hideUI()
QBoxLayout * iLayout
Definition: controller.h:301
Node * iNode
Definition: controller.h:312
Class that will initiate 1 or more network connections.
Definition: networkconnectorengine.h:45
virtual void displayAboutBox()
virtual void deleteProfile()
virtual QString displayableNameForProfile(const Hash &aProfileFingerPrint) const
virtual MVoiceCallEngine * voiceCallEngineInterface()
QAction * iDisplaySearchAct
Definition: controller.h:311
Hash iHashOfProfileCommentBeingWaitedFor
Definition: controller.h:338
void waitDialogToBeDismissed()
Work queue item.
Definition: netrequestexecutor.h:60
RetrievalEngine * iRetrievalEngine
Definition: controller.h:319
virtual void changeProfilePasswd()
virtual void displayStatus()
QAction * iDisplayStatusAct
Definition: controller.h:310
Network-connection logic relating content publish demands.
Definition: publishingengine.h:41
PublishingEngine * iPubEngine
Definition: controller.h:318
void notifyOfContentReceived(const Hash &aHashOfContent, const ProtocolItemType aTypeOfReceivedContent)
virtual void setProfileInUse(const Hash &aProfileHash)
Network-related logic for handling voice channel between nodes.
Definition: voicecallengine.h:53
QMap< Hash, QString > iHashDisplaynameMapping
Definition: controller.h:347
QAction * iPwdChangeAct
Definition: controller.h:305
virtual void reStorePrivateDataOfSelectedProfile()
NetworkConnectorEngine * iNetEngine
Definition: controller.h:315
Model * iModel
Definition: controller.h:313
void createMenus()
ProtocolItemType iTypeOfObjectBeingWaitedFor
Definition: controller.h:326