Index: sources/device/DeviceController.cpp =================================================================== diff -u -r389f028cb9d4d320eae393de7c4408a58a619356 -r1da89b0452b8ef9448847618e75c118f3f58bd0c --- sources/device/DeviceController.cpp (.../DeviceController.cpp) (revision 389f028cb9d4d320eae393de7c4408a58a619356) +++ sources/device/DeviceController.cpp (.../DeviceController.cpp) (revision 1da89b0452b8ef9448847618e75c118f3f58bd0c) @@ -31,6 +31,7 @@ #include "FileHandler.h" #include "DeviceModels.h" #include "Settings.h" +#include "encryption.h" // namespace using namespace Model; @@ -107,8 +108,14 @@ connect(&_fileSystemWatcher , SIGNAL( fileChanged(const QString &)), this , SLOT( onWatchFileChanged(const QString &))); - connect(&_ApplicationController , SIGNAL(didPOSTInformationReady(const QString &, const QString &, const QString &)), - this , SLOT( onPOSTInformationReady(const QString &, const QString &, const QString &))); + connect(&_ApplicationController , SIGNAL(didPOSTEthernetData (const QString &)), + this , SLOT( onPOSTEthernetData (const QString &))); + connect(&_ApplicationController , SIGNAL(didPOSTWirelessData (const QString &)), + this , SLOT( onPOSTWirelessData (const QString &))); + connect(&_ApplicationController , SIGNAL(didPOSTBluetoothData (const QString &)), + this , SLOT( onPOSTBluetoothData (const QString &))); + connect(&_ApplicationController , SIGNAL(didPOSTCloudSyncData (const QString &)), + this , SLOT( onPOSTCloudSyncData (const QString &))); DEVICE_DEV_INIT_CONNECTIONS_LIST @@ -566,6 +573,8 @@ */ void DeviceController::onAttributeRequest(const DeviceCryptSetupRequestData &vData) { + qDebug() << " ---------- " << vData.mCommand << vData.mPassword; + _deviceCryptSetupRequest._data = vData; // ----- check that script exists. @@ -586,9 +595,10 @@ _processCryptSetup.setEnvironment(QProcess::systemEnvironment() << QString("PASSWORD=%1").arg(_deviceCryptSetupRequest._data.mPassword)); timedProcess->start(); + // Update UI with a response MDeviceCryptSetupResponse model; - model._data.mAccepted = false; - model._data.mMessage = tr("Encrypted Partition %1 started.").arg(_deviceCryptSetupRequest._data.mCommand); + model._data.mAccepted = false; + model._data.mMessage = tr("Encrypted Partition %1 started.").arg(_deviceCryptSetupRequest._data.mCommand); emit didAttributeResponse(model.data()); } @@ -611,9 +621,11 @@ emit didAttributeResponse(model.data()); LOG_APPED_UI(model.data().mMessage); + if ( _deviceCryptSetupRequest._data.mCommand == "mount" ) emit didCryptSetupMount(model._data.mAccepted); // move the configuration files if the encrypted partition creation was successful. - if ( ! model._data.mAccepted ) return; + if ( _deviceCryptSetupRequest._data.mCommand != "setup" ) return; + if ( ! model._data.mAccepted ) return; QString msg = ""; int err = 0 ; //TODO The Settings shall be the Singleton SettingsController and modify the MSettings like the others. @@ -740,20 +752,64 @@ emit didWatchFileChange(vFile); } -void DeviceController::onPOSTInformationReady(const QString &vMacEthernet, const QString &vMacWireless, const QString &vMacBluetooth) -{ - _macEthernet = vMacEthernet .trimmed(); - _macWireless = vMacWireless .trimmed(); - _macBluetooth = vMacBluetooth .trimmed(); -} - void DeviceController::onEventThreadChange() { qDebug() << " ---------- " << __FUNCTION__ << QThread::currentThread()->objectName() << QThread::currentThread() << qApp->thread(); if ( QThread::currentThread() != &Threads::_DeviceController_Thread ) { qCritical() << " ***** Device controller thread not initialized correctly ***** "; + return; } + _hasThread = true; + checkConfugurationMountReady(); +} +void DeviceController::onPOSTEthernetData(const QString &vMacAddress) { + _macEthernet = vMacAddress; + emit didPOSTEthernetData (vMacAddress); +} + +void DeviceController::onPOSTWirelessData(const QString &vMacAddress) { + _macWireless = vMacAddress; + + encryption::varSalt(vMacAddress); + _hasSalt = ! vMacAddress.trimmed().isEmpty(); + checkConfugurationMountReady(); + + emit didPOSTWirelessData (vMacAddress); +} + +void DeviceController::onPOSTBluetoothData(const QString &vMacAddress) { + _macBluetooth = vMacAddress; + emit didPOSTBluetoothData (vMacAddress); +} + +void DeviceController::onPOSTCloudSyncData(const QString &vNetAddress) { + _netCloudSync = vNetAddress; + emit didPOSTCloudSyncData (vNetAddress); +} + +void DeviceController::checkConfugurationMountReady() +{ + /// in manufacturing the system is logged with root and configurations are in /home/root + /// therefore no need to mount the cononfiguraiton partition. + /// also for in manufacturing the partition is being set up + /// and is less steps for setup if the partition is not mounted. + if ( gEnableManufacturing ) return; + + + if ( ! ( _hasThread && _hasSalt ) ) return; + + DeviceCryptSetupRequestData data; + data.mCommand = "mount"; + bool ok = false; + data.mPassword = encryption::configurationsPassword( ok ); + if ( ! ok ) { // not enough infromation to create a secure passowrd + // status(tr("Not enough secure information provided")); + } + else { + onAttributeRequest(data); + } + // I_AM_HERE // HERE move the settings read from ApplicationController to here // here is when the DeviceController is moved to its thread @@ -762,4 +818,3 @@ // TODO don't forget to check for the required configurations files and parameters in the settings class. // and take care of the security flag in the Storage class. } -