1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191
|
/* -*-C++-*- -*-coding: utf-8-unix;-*-
Classified Ads is Copyright (c) Antti Järvinen 2013-2022.
This file is part of Classified Ads.
Classified Ads is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
Classified Ads is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with Classified Ads; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#include "mockup_controller.h"
#include "../log.h"
#include "../net/node.h"
#include "../datamodel/model.h"
#include "../net/networklistener.h"
#include "../net/networkconnectorengine.h"
#include <unistd.h> // for getpid()
#include <signal.h>
#include "../datamodel/binaryfile.h"
#include "mockup_voicecallengine.h"
#include "../tcl/tclWrapper.h"
#include <QDir>
#include <QUuid>
MockUpController::MockUpController() :
iNode(NULL),
iModel(NULL),
iListener(NULL),
iCallEngine(NULL),
iTclWrapper(NULL) {
LOG_STR("MockUpController::Controller in\n") ;
qRegisterMetaType<MController::CAErrorSituation>("MController::CAErrorSituation");
iModel = new Model(this);
iNode = new Node(iModel->nodeModel().nodeFingerPrint(),
iModel->nodeModel().listenPortOfThisNode()) ;
iListener = new NetworkListener (this, iModel) ;
// network listener enumerates network interfaces and sets
// possible ipv6 addr into iNode() ->
iCallEngine = new MockUpVoiceCallEngine ;
iTclWrapper = new TclWrapper(*iModel, *this) ;
LOG_STR("MockUpController::Controller out\n") ;
}
MockUpController::~MockUpController() {
LOG_STR("MockUpController::~Controller\n") ;
// .. connections reference iListener.
// so in order to prevent random crash at closing, lets first get rid
// of connections, only after that delete iListener ;
iModel->closeAllConnections(true) ;
// now safe to delete listener (and net engine)
delete iListener ; // will delete also connections received by listener
delete iModel ;
delete iNode ;
delete iCallEngine ;
delete iTclWrapper ;
}
void MockUpController::userInterfaceAction ( CAUserInterfaceRequest aRequest,
const Hash& aHashConcerned,
const Hash& aFetchFromNode,
const QString* /*aAdditionalInformation*/ ) {
LOG_STR2("MockUpController::userInterfaceAction %d\n", (int) aRequest) ;
}
void MockUpController::hideUI() {
}
void MockUpController::showUI() {
}
void MockUpController::exitApp() {
}
void MockUpController::displayAboutBox() {
}
void MockUpController::displayFront() {
LOG_STR("displayFront\n") ;
}
void MockUpController::handleError(MController::CAErrorSituation aError,
const QString& aExplanation) {
LOG_STR2("Error enum value %d\n", aError) ;
QLOG_STR(aExplanation) ;
switch ( aError ) {
case DataBaseNotMountable:
LOG_STR("Can't open DB\n") ;
break ;
}
return ;
}
Node& MockUpController::getNode() const {
return *iNode ;
}
NetworkListener *MockUpController::networkListener() const {
return iListener ;
}
Model& MockUpController::model() const {
return *iModel ;
}
void MockUpController::setContentKeyPasswd(QString aPasswd) {
iContentPasswd = aPasswd ;
}
QString MockUpController::contentKeyPasswd() const {
return iContentPasswd ;
}
void MockUpController::setProfileInUse(const Hash& aProfileHash) {
iProfileHash = aProfileHash ;
}
const Hash& MockUpController::profileInUse() {
return iProfileHash;
}
void MockUpController::startRetrievingContent(NetworkRequestExecutor::NetworkRequestQueueItem aReq,bool aIsBackgroundDl, ProtocolItemType aTypeOfExpectedObject) {
return ;
}
void MockUpController::startRetrievingContent(CaDbRecord::SearchTerms /*aSearchTerms*/) {
return ;
}
void MockUpController::storePrivateDataOfSelectedProfile(bool /*aPublishTrustListToo*/) {
return ;
}
void MockUpController::reStorePrivateDataOfSelectedProfile() {
return ;
}
bool MockUpController::isContactInContactList(const Hash& aFingerPrint) const {
return true ;
}
QString MockUpController::displayableNameForProfile(const Hash& aProfileFingerPrint) const {
return "eino leino reino" ;
}
void MockUpController::offerDisplayNameForProfile(const Hash& aProfileFingerPrint,
const QString& aDisplayName,
const bool iUpdatePersistenStorage) {
return ;
}
void MockUpController::displayFileInfoOnUi(const BinaryFile& aFileMetadata) {
QLOG_STR("displayFileInfoOnUi file = " + aFileMetadata.iFileName) ;
}
MVoiceCallEngine* MockUpController::voiceCallEngineInterface() {
return iCallEngine ;
}
TclWrapper& MockUpController::tclWrapper() {
return *iTclWrapper ;
}
QString MockUpController::getFileName(bool& aSuccess,
bool /*aIsSaveFile*/ ,
QString /*aSuggestedFileName*/) {
aSuccess = true ;
// mimic a temporary file name here:
QString s ( QDir::tempPath() );
s.append(QDir::separator()) ;
s.append(QUuid::createUuid().toString(QUuid::WithoutBraces)) ;
return s ;
}
|