Classified ads
Public Slots | Signals | Public Member Functions | Private Slots | Private Member Functions | Private Attributes | List of all members
Controller Class Reference

Class for keeping app state. More...

#include <controller.h>

Inheritance diagram for Controller:
Inheritance graph
[legend]
Collaboration diagram for Controller:
Collaboration graph
[legend]

Public Slots

virtual void exitApp ()
 
virtual void displayAboutBox ()
 
virtual void displayFront ()
 
virtual void changeProfilePasswd ()
 
virtual void createProfile ()
 
virtual void deleteProfile ()
 
virtual void selectProfile ()
 
virtual void displaySettings ()
 
virtual void displayStatus ()
 
virtual void displaySearch ()
 
virtual void displayTclProgs ()
 
virtual void displayTclConsole ()
 
virtual void handleError (MController::CAErrorSituation aError, const QString &aExplanation)
 
void notifyOfContentReceived (const Hash &aHashOfContent, const ProtocolItemType aTypeOfReceivedContent)
 
void notifyOfContentReceived (const Hash &aHashOfContent, const Hash &aHashOfClassification, const ProtocolItemType aTypeOfReceivedContent)
 
void notifyOfContentNotReceived (const Hash &aHashOfContent, const ProtocolItemType aTypeOfNotReceivdContent)
 
virtual void storePrivateDataOfSelectedProfile (bool aPublishTrustListToo=false)
 
virtual void reStorePrivateDataOfSelectedProfile ()
 
virtual bool isContactInContactList (const Hash &aFingerPrint) const
 
virtual QString displayableNameForProfile (const Hash &aProfileFingerPrint) const
 
virtual void offerDisplayNameForProfile (const Hash &aProfileFingerPrint, const QString &aDisplayName, const bool iUpdatePersistenStorage=false)
 
virtual void displayFileInfoOnUi (const BinaryFile &aFileMetadata)
 
virtual VoiceCallEnginevoiceCallEngine ()
 
virtual MVoiceCallEnginevoiceCallEngineInterface ()
 
virtual TclWrappertclWrapper ()
 
virtual QWidget * frontWidget ()
 
void sendProfileUpdateQuery (const Hash &aProfileFingerPrint, const Hash &aProfileNodeFingerPrint=KNullHash)
 
virtual QString getFileName (bool &aSuccess, bool aIsSaveFile=false, QString aSuggestedFileName=QString())
 
- Public Slots inherited from MController
virtual void exitApp ()=0
 
virtual void displayAboutBox ()=0
 
virtual void displayFront ()=0
 
virtual void handleError (MController::CAErrorSituation aError, const QString &aExplanation)=0
 
virtual void storePrivateDataOfSelectedProfile (bool aPublishTrustListToo=false)=0
 
virtual void reStorePrivateDataOfSelectedProfile ()=0
 
virtual bool isContactInContactList (const Hash &aFingerPrint) const =0
 
virtual QString displayableNameForProfile (const Hash &aProfileFingerPrint) const =0
 
virtual void offerDisplayNameForProfile (const Hash &aProfileFingerPrint, const QString &aDisplayName, const bool iUpdatePersistenStorage=false)=0
 
virtual void displayFileInfoOnUi (const BinaryFile &aFileMetadata)=0
 
virtual VoiceCallEnginevoiceCallEngine ()=0
 
virtual MVoiceCallEnginevoiceCallEngineInterface ()=0
 
virtual TclWrappertclWrapper ()=0
 
virtual QWidget * frontWidget ()=0
 
virtual QString getFileName (bool &aSuccess, bool aIsSaveFile=false, QString aSuggestedFileName=QString())=0
 

Signals

void userProfileSelected (const Hash &aProfile)
 
void waitDialogToBeDismissed ()
 
void startGettingFileName (QString aSuggestedFileName, bool aIsSaveFile)
 

Public Member Functions

 Controller (QApplication &app)
 
 ~Controller ()
 
bool init ()
 
virtual void startRetrievingContent (NetworkRequestExecutor::NetworkRequestQueueItem aReq, bool aIsBackgroundDl, ProtocolItemType aTypeOfExpectedObject)
 
virtual void startRetrievingContent (CaDbRecord::SearchTerms aSearchTerms)
 
virtual void userInterfaceAction (CAUserInterfaceRequest aRequest, const Hash &aHashConcerned=KNullHash, const Hash &aFetchFromNode=KNullHash, const QString *aAdditionalInformation=NULL)
 
virtual void hideUI ()
 
virtual void showUI ()
 
virtual void setProfileInUse (const Hash &aProfileHash)
 
virtual const HashprofileInUse ()
 
virtual void setContentKeyPasswd (QString aPasswd)
 
virtual QString contentKeyPasswd () const
 
virtual NodegetNode () const
 
virtual NetworkListenernetworkListener () const
 
virtual Modelmodel () const
 
void addObjectToOpen (QUrl aClassifiedAdsObject)
 
void checkForSharedMemoryContents ()
 

Private Slots

void checkForObjectToOpen (const Hash &aIgnored)
 
void getFileNameSlot (QString aSuggestedFileName, bool aIsSaveFile)
 

Private Member Functions

void createMenus ()
 
int createPidFile ()
 
void deletePidFile ()
 
bool createSharedMemSegment (QString &aSegmentName)
 

Private Attributes

QMainWindow * iWin
 
FrontWidgetiCurrentWidget
 
QApplication & iApp
 
QBoxLayout * iLayout
 
QMenu * iFileMenu
 
QAction * iExitAct
 
QAction * iAboutAct
 
QAction * iPwdChangeAct
 
QAction * iProfileDeleteAct
 
QAction * iProfileCreateAct
 
QAction * iProfileSelectAct
 
QAction * iDisplaySettingsAct
 
QAction * iDisplayStatusAct
 
QAction * iDisplaySearchAct
 
QMenu * iTclMenu
 
QAction * iTclLibraryAct
 
QAction * iTclConsoleAct
 
NodeiNode
 
ModeliModel
 
NetworkListeneriListener
 
NetworkConnectorEngineiNetEngine
 
QString iContentKeyPasswd
 
Hash iProfileHash
 
PublishingEngineiPubEngine
 
RetrievalEngineiRetrievalEngine
 
DbRecordRetrievalEngineiDbRetrievalEngine
 
ProtocolItemType iTypeOfObjectBeingWaitedFor
 
Hash iHashOfObjectBeingWaitedFor
 
Hash iHashOfProfileCommentBeingWaitedFor
 
Hash iNodeForCommentBeingWaitedFor
 
QMap< Hash, QString > iHashDisplaynameMapping
 
VoiceCallEngineiVoiceCallEngine
 
bool iInsideDestructor
 
QUrl iObjectToOpen
 
QSharedMemory * iSharedMemory
 
TclWrapperiTclWrapper
 
QString iGetFileNameResult
 
QFileDialog * iGetFileNameDialog
 
QSemaphore iGetFileNameSemaphore
 
bool iGetFileNameSuccess
 

Additional Inherited Members

- Public Types inherited from MController
enum  CAErrorSituation {
  OwnCertNotFound, DataBaseNotMountable, BadPassword, DbTransactionError,
  ContentEncryptionError, FileOperationError, TCLEvalError
}
 
enum  CAUserInterfaceRequest {
  ViewProfileDetails, ViewCa, ViewProfileComment, DisplayProgressDialog,
  VoiceCallToNode
}
 

Detailed Description

Class for keeping app state.

C of MVC-pattern is considered here. UI events are routed via this class and this implements scheduling of events so that things happen in correct order.

Constructor & Destructor Documentation

◆ Controller()

Controller::Controller ( QApplication &  app)

constructor. see also method .

◆ ~Controller()

Controller::~Controller ( )

Destructor

Member Function Documentation

◆ addObjectToOpen()

void Controller::addObjectToOpen ( QUrl  aClassifiedAdsObject)

method for setting an URL to open. Url is opened only if it is of classified-ads URL scheme, currently supported protocols are caprofile, caad, cacomment and cablob and if URL scheme is not among those, this method does no thing. Host part contains hash of object, other parts are ignored.

Parameters
aClassifiedAdsObjectobject to bring visible to user

◆ changeProfilePasswd

virtual void Controller::changeProfilePasswd ( )
virtualslot

name says it all. initiates UI sequence

◆ checkForObjectToOpen

void Controller::checkForObjectToOpen ( const Hash aIgnored)
privateslot

◆ checkForSharedMemoryContents()

void Controller::checkForSharedMemoryContents ( )

method called if old instance of this program is signaled from new instace, calling for this instance to bring itself to front, and, in this method, to check if there is object mentioned in shared memory segment that needs to be displayed

◆ contentKeyPasswd()

virtual QString Controller::contentKeyPasswd ( ) const
virtual

method for getting passwd of private content keys previously set, see method Controller::setContentKeyPasswd

Implements MController.

◆ createMenus()

void Controller::createMenus ( )
private

menus here

◆ createPidFile()

int Controller::createPidFile ( )
private

leave a mark to filesystem about instance

◆ createProfile

virtual void Controller::createProfile ( )
virtualslot

Initiates UI sequence for new profile

◆ createSharedMemSegment()

bool Controller::createSharedMemSegment ( QString &  aSegmentName)
private

creates and possibly populates a shared memory segment for IPC needs

◆ deletePidFile()

void Controller::deletePidFile ( )
private

remove mark from filesystem about instance

◆ deleteProfile

virtual void Controller::deleteProfile ( )
virtualslot

Initiates UI sequence for deleting profile

◆ displayableNameForProfile

virtual QString Controller::displayableNameForProfile ( const Hash aProfileFingerPrint) const
virtualslot

method for producing a displayable version of a profile. in practice this utilitizes the contacts of the selected profile and a cache that is collected from private messages, ads, profile comments and profiles

◆ displayAboutBox

virtual void Controller::displayAboutBox ( )
virtualslot

bragging

◆ displayFileInfoOnUi

virtual void Controller::displayFileInfoOnUi ( const BinaryFile aFileMetadata)
virtualslot

method that puts dialog or similar on display, about a published file

◆ displayFront

virtual void Controller::displayFront ( )
virtualslot

this initializes the "normal" display

◆ displaySearch

virtual void Controller::displaySearch ( )
virtualslot

Slot for displaying search dialog

◆ displaySettings

virtual void Controller::displaySettings ( )
virtualslot

Slot for displaying node settings

◆ displayStatus

virtual void Controller::displayStatus ( )
virtualslot

Slot for displaying network status

◆ displayTclConsole

virtual void Controller::displayTclConsole ( )
virtualslot

Slot for displaying TCL console

◆ displayTclProgs

virtual void Controller::displayTclProgs ( )
virtualslot

Slot for displaying TCL library

◆ exitApp

virtual void Controller::exitApp ( )
virtualslot

quitting

◆ frontWidget

virtual QWidget* Controller::frontWidget ( )
virtualslot

Method for getting front-widget, to be used as parent of dialogs spawned from non-ui threads. From MController interface.

◆ getFileName

virtual QString Controller::getFileName ( bool &  aSuccess,
bool  aIsSaveFile = false,
QString  aSuggestedFileName = QString() 
)
virtualslot

Method for getting file name. Method displays file selection dialog and returns the selected file. Idea of this method is that it may be called from background threads and it will display the dialog in UI thread, then report results back. This is a blocking method that will suspend execution of the calling thread for the duration while user is doing the selection.

Parameters
aSuccessis set to true if operation ends all right.
aIsSaveFileif set to true, "file save" dialog is shown, otherwise "file open" dialog.
aSuggestedFileNamefile name (pattern). If given empty, any file is suggested in dialog, if "*.jpg" is given, then dialog shall suggest only files with .jpg ending and if "foobar.txt" is given, then dialog will suggest literal file name "foobar.txt".
Returns
file system file name or empty if aSuccess is set to false.

◆ getFileNameSlot

void Controller::getFileNameSlot ( QString  aSuggestedFileName,
bool  aIsSaveFile 
)
privateslot

processing of method addObjectToOpen worker-slot for getFileName method ; this slot will be called in queued manner and have its code run in UI thread.

◆ getNode()

virtual Node& Controller::getNode ( ) const
virtual

Method for node ; this may be changed during startup-phase but not after that

Implements MController.

◆ handleError

virtual void Controller::handleError ( MController::CAErrorSituation  aError,
const QString &  aExplanation 
)
virtualslot

Method for handling errors inside application.

Parameters
aErrorReason for error call, from error enum above
aExplanationNULL or human-readable description about what went wrong.

◆ hideUI()

virtual void Controller::hideUI ( )
virtual

method for hiding UI

Implements MController.

◆ init()

bool Controller::init ( )

Constructor extras. Constructor may fail but there is no way to communicate that. Design is now so that constructor only allocates memory and initializes member variables, this method here, contains constructor logic and it may fail.

Returns
true if initialization is ok

◆ isContactInContactList

virtual bool Controller::isContactInContactList ( const Hash aFingerPrint) const
virtualslot

method for checking if a profile is found from contact list of selected user

◆ model()

virtual Model& Controller::model ( ) const
virtual

method for getting datamodel

Implements MController.

◆ networkListener()

virtual NetworkListener* Controller::networkListener ( ) const
virtual

method for network listener ; it is parent of all connections, also the outgoing

Implements MController.

◆ notifyOfContentNotReceived

void Controller::notifyOfContentNotReceived ( const Hash aHashOfContent,
const ProtocolItemType  aTypeOfNotReceivdContent 
)
slot

This is receiving slot of signals sent from retrieval engine; when we try to receive content and we do not get any, this notifies user that time-out is due

Parameters
aHashOfContentitem that was requested
aTypeOfNotReceivdContentitem type requested

◆ notifyOfContentReceived [1/2]

void Controller::notifyOfContentReceived ( const Hash aHashOfContent,
const ProtocolItemType  aTypeOfReceivedContent 
)
slot

This is receiving slot of signals sent from actual content handlers ; when we receive new content, this method is hit, reason for this is that we may be waiting for specific content somewhere

Parameters
aHashOfContentitem that was requested
aTypeOfReceivedContentitem type requested

◆ notifyOfContentReceived [2/2]

void Controller::notifyOfContentReceived ( const Hash aHashOfContent,
const Hash aHashOfClassification,
const ProtocolItemType  aTypeOfReceivedContent 
)
slot

This is receiving slot of signals sent from actual content handlers ; when we receive new content, this method is hit, reason for this is that we may be waiting for specific content somewhere. This overload is mostly hit by classified ads.

Parameters
aHashOfContentitem that was requested
aHashOfClassificationof item that was requested
aTypeOfReceivedContentitem type requested

◆ offerDisplayNameForProfile

virtual void Controller::offerDisplayNameForProfile ( const Hash aProfileFingerPrint,
const QString &  aDisplayName,
const bool  iUpdatePersistenStorage = false 
)
virtualslot

method for keeping profile hash<->displayname relation up to date. this is called when display names are seen in profiles, ads, private messages etc.

◆ profileInUse()

virtual const Hash& Controller::profileInUse ( )
virtual

method getting user profile in use.

Implements MController.

◆ reStorePrivateDataOfSelectedProfile

virtual void Controller::reStorePrivateDataOfSelectedProfile ( )
virtualslot

method for restoring private data of profile currently in use. shall be called after new profile is selected in frontwidget.

◆ selectProfile

virtual void Controller::selectProfile ( )
virtualslot

Initiates UI sequence for selecting profile

◆ sendProfileUpdateQuery

void Controller::sendProfileUpdateQuery ( const Hash aProfileFingerPrint,
const Hash aProfileNodeFingerPrint = KNullHash 
)
slot

method for sending a poll around network regarding possible update for a profile and possible addition of comments about given profile.

datamodel should not be locked when this is called.

in practice this is called after user selects a profile to be viewed ; it could be called periodically too for selected profiles..

Parameters
aProfileFingerPrintis fingerprint of the profile concerned.
aProfileNodeFingerPrintfingerprint of node that is suspected to be the node where profile is published from. this is naturally good candidate for sending the query.

◆ setContentKeyPasswd()

virtual void Controller::setContentKeyPasswd ( QString  aPasswd)
virtual

method for setting passwd used to open private content encryption rsa key. this password is stored in controller and is then used by content-open/sign-operations when crypto lib asks for password.

Implements MController.

◆ setProfileInUse()

virtual void Controller::setProfileInUse ( const Hash aProfileHash)
virtual

method selecting user profile in use.

Implements MController.

◆ showUI()

virtual void Controller::showUI ( )
virtual

method for showing UI

Implements MController.

◆ startGettingFileName

void Controller::startGettingFileName ( QString  aSuggestedFileName,
bool  aIsSaveFile 
)
signal

signal for launching file selection dlg

◆ startRetrievingContent() [1/2]

virtual void Controller::startRetrievingContent ( NetworkRequestExecutor::NetworkRequestQueueItem  aReq,
bool  aIsBackgroundDl,
ProtocolItemType  aTypeOfExpectedObject 
)
virtual

method that starts actions regarding content fetch from network

Parameters
aReqspecifies the content,at least iRequestType and iRequestedItem need to be there
aIsBackgroundDlis true if the retrieval may be queued into background as a low-priority item

Implements MController.

◆ startRetrievingContent() [2/2]

virtual void Controller::startRetrievingContent ( CaDbRecord::SearchTerms  aSearchTerms)
virtual

Variant of "start fetch" method that starts fetch of db records.

Parameters
aSearchTermsDatabase query that fetched record should satisfy

Implements MController.

◆ storePrivateDataOfSelectedProfile

virtual void Controller::storePrivateDataOfSelectedProfile ( bool  aPublishTrustListToo = false)
virtualslot

Method for persisting profile private data inside datamodel. Tnis is supposed to be called every time after private data changes.

lock the datamodel before calling this method

Parameters
aPublishTrustListTooif set to true, has selected profiles trust list to be updated profile data and profile published with the new trust list.

◆ tclWrapper

virtual TclWrapper& Controller::tclWrapper ( )
virtualslot

Method for getting tcl wrapper instance. If there is no instance one will be created. From MController interface.

◆ userInterfaceAction()

virtual void Controller::userInterfaceAction ( CAUserInterfaceRequest  aRequest,
const Hash aHashConcerned = KNullHash,
const Hash aFetchFromNode = KNullHash,
const QString *  aAdditionalInformation = NULL 
)
virtual

From MController.

Method for requesting different things to take place in UI. controller mostly routes these to FrontWidget but other actions may be in order too..

Parameters
aRequestusers orders
aHashConcernedpossible hash parameter ; can be null hash if action is not about specific hash
aFetchFromNodepossible node hash parameter ; if concerning item is not found from local storage, try to fetch it from given node ; is KNullHash, then just do fetch using normal algorithm.
aAdditionalInformationpossible explanation or other info
Returns
none

Implements MController.

◆ userProfileSelected

void Controller::userProfileSelected ( const Hash aProfile)
signal

◆ voiceCallEngine

virtual VoiceCallEngine* Controller::voiceCallEngine ( )
virtualslot

Method for getting voice call engine, if there is any. From MController interface.

Returns
engine or null

◆ voiceCallEngineInterface

virtual MVoiceCallEngine* Controller::voiceCallEngineInterface ( )
virtualslot

Method for getting voice call engine, if there is any. From MController interface.

Returns
engine or mockup. In normal runtime this just calls voiceCallEngine.

◆ waitDialogToBeDismissed

void Controller::waitDialogToBeDismissed ( )
signal

used for signalling possible wait dialog about dismissal

Member Data Documentation

◆ iAboutAct

QAction* Controller::iAboutAct
private

◆ iApp

QApplication& Controller::iApp
private

◆ iContentKeyPasswd

QString Controller::iContentKeyPasswd
private

◆ iCurrentWidget

FrontWidget* Controller::iCurrentWidget
private

normally points to "frontwidget" instance

◆ iDbRetrievalEngine

DbRecordRetrievalEngine* Controller::iDbRetrievalEngine
private

Logic for fetcing db records from other nodes

◆ iDisplaySearchAct

QAction* Controller::iDisplaySearchAct
private

◆ iDisplaySettingsAct

QAction* Controller::iDisplaySettingsAct
private

◆ iDisplayStatusAct

QAction* Controller::iDisplayStatusAct
private

◆ iExitAct

QAction* Controller::iExitAct
private

◆ iFileMenu

QMenu* Controller::iFileMenu
private

◆ iGetFileNameDialog

QFileDialog* Controller::iGetFileNameDialog
private

variable used in getFileName wrapper: points to dialog

◆ iGetFileNameResult

QString Controller::iGetFileNameResult
private

variable used in getFileName wrapper: holds result string

◆ iGetFileNameSemaphore

QSemaphore Controller::iGetFileNameSemaphore
private

variable used in getFileName wrapper: mutex that is locked for duration while iGetFileNameDialog is on display

◆ iGetFileNameSuccess

bool Controller::iGetFileNameSuccess
private

variable used in getFileName wrapper: result from file selection dialog

◆ iHashDisplaynameMapping

QMap<Hash,QString> Controller::iHashDisplaynameMapping
private

profile hash<->display_name mapping

◆ iHashOfObjectBeingWaitedFor

Hash Controller::iHashOfObjectBeingWaitedFor
private

hash of object that user needs to wait.

◆ iHashOfProfileCommentBeingWaitedFor

Hash Controller::iHashOfProfileCommentBeingWaitedFor
private

hash of profile comment that user needs to wait. This is used in two-stage fetch process of profile comment where the profile may need to be retrieved first, then the comment: we store there the profile comment hash for duration of profile fetch

◆ iInsideDestructor

bool Controller::iInsideDestructor
private

Flag for destructor. If this is on, don't allocate more objects

◆ iLayout

QBoxLayout* Controller::iLayout
private

◆ iListener

NetworkListener* Controller::iListener
private

Incoming connections handler, for ipv4

◆ iModel

Model* Controller::iModel
private

data storage animal

◆ iNetEngine

NetworkConnectorEngine* Controller::iNetEngine
private

Outgoing connections handler

◆ iNode

Node* Controller::iNode
private

our network presence object, there is single instance

◆ iNodeForCommentBeingWaitedFor

Hash Controller::iNodeForCommentBeingWaitedFor
private

Node where to ask for profile comment once profile has been fetched

◆ iObjectToOpen

QUrl Controller::iObjectToOpen
private

pending object to open

◆ iProfileCreateAct

QAction* Controller::iProfileCreateAct
private

◆ iProfileDeleteAct

QAction* Controller::iProfileDeleteAct
private

◆ iProfileHash

Hash Controller::iProfileHash
private

passwd used to protect profile private RSA key fingerprint of profile currently in use

◆ iProfileSelectAct

QAction* Controller::iProfileSelectAct
private

◆ iPubEngine

PublishingEngine* Controller::iPubEngine
private

Logic for handling content publish

◆ iPwdChangeAct

QAction* Controller::iPwdChangeAct
private

◆ iRetrievalEngine

RetrievalEngine* Controller::iRetrievalEngine
private

Logic for fetcing stuff from other nodes

◆ iSharedMemory

QSharedMemory* Controller::iSharedMemory
private

Shared memory block for receiving iObjectToOpen from external process.

◆ iTclConsoleAct

QAction* Controller::iTclConsoleAct
private

Menu item for opening tcl console dialog

◆ iTclLibraryAct

QAction* Controller::iTclLibraryAct
private

Menu item for opening tcl lib dialog

◆ iTclMenu

QMenu* Controller::iTclMenu
private

◆ iTclWrapper

TclWrapper* Controller::iTclWrapper
private

wraps TCL interpreter

◆ iTypeOfObjectBeingWaitedFor

ProtocolItemType Controller::iTypeOfObjectBeingWaitedFor
private

if user requests for item that we do not have, lets put a wait dialog in place and start wait for the object to appear from network. in order to properly dismiss the dialog, have here type (and later hash) of the objects that we're waiting for

◆ iVoiceCallEngine

VoiceCallEngine* Controller::iVoiceCallEngine
private

Currently there is support for one voice call at time

◆ iWin

QMainWindow* Controller::iWin
private

The documentation for this class was generated from the following file: