Index: sources/gui/qml/pages/settings/SettingsServicePassword.qml =================================================================== diff -u -r789c41cc050e48a9821c3e771791c8907907b63c -r7ec98d237f871e5d1206809d309da6d57a086d28 --- sources/gui/qml/pages/settings/SettingsServicePassword.qml (.../SettingsServicePassword.qml) (revision 789c41cc050e48a9821c3e771791c8907907b63c) +++ sources/gui/qml/pages/settings/SettingsServicePassword.qml (.../SettingsServicePassword.qml) (revision 7ec98d237f871e5d1206809d309da6d57a086d28) @@ -28,8 +28,10 @@ itemIndex : SettingsStack.ServicePassword property bool isPassword_Accepted : false - property bool isDefaultPasswordSet : (vSettings.servicePass != "") + property bool isDefaultPasswordSet : vSettings.isPasswordSet + onIsDefaultPasswordSetChanged: console.log(isDefaultPasswordSet) + backVisible : ! _GuiView.manufactSetup title : isDefaultPasswordSet ? qsTr("Service Password") : qsTr("Set Service Password") isPassword : true Index: sources/view/settings/VSettings.cpp =================================================================== diff -u -rd949be21f2a9badd0978dddaaf436f6805de28dc -r7ec98d237f871e5d1206809d309da6d57a086d28 --- sources/view/settings/VSettings.cpp (.../VSettings.cpp) (revision d949be21f2a9badd0978dddaaf436f6805de28dc) +++ sources/view/settings/VSettings.cpp (.../VSettings.cpp) (revision 7ec98d237f871e5d1206809d309da6d57a086d28) @@ -126,6 +126,8 @@ roWaterMode ( _roWaterMode ); // noCANBus ( _noCANBus ); // This line has been put here to remind developers that it is intentionally removed, to not to add a default value. + isPasswordSet ( ! isPasswordDefault() ); + adjustment(true); } @@ -268,6 +270,12 @@ #include +/*! + * \brief VSettings::encryptString + * \details encrypts the string vString with an algorithm + * \param vString - the string to be encrypted. + * \return encrypted string + */ QString VSettings::encryptString(const QString &vString) { // FIXME: Move this to the utility, storage or settings controller class for more general use. QString salt = "DVT-HD0004"; // FIXME: Use the actual HD serial number @@ -283,11 +291,47 @@ return hashed.toHex(); } +/*! + * \brief View::VSettings::isPasswordMatch + * \details matches the given password string, vPassword, with the service password. + * \param vPassword - the given password string + * \return true if it matches. + */ bool View::VSettings::isPasswordMatch(const QString &vPassword) { return _servicePass == encryptString(vPassword); } +/*! + * \brief View::VSettings::updatePassword + * \details Updatest the service password with the given password. + * \param vPassword - the password to be saved as the service password. + */ void View::VSettings::updatePassword(const QString &vPassword) { servicePass(encryptString(vPassword)); } + +/*! + * \brief View::VSettings::isPasswordDefault + * \details Checks if the current service password is the default password + * \note It is being used to force the user/manufacturer to set the service password. + * \return true if the service password is the default. + */ +bool View::VSettings::isPasswordDefault() +{ + return servicePass() == defaultPassword(); +} + +/*! + * \brief View::VSettings::defaultPassword + * \details The default password which will be used as an indication that the service password has not been set yet. + * \return the default password as encrypted string. + */ +QString View::VSettings::defaultPassword() +{ + QString _A1 = "tal"; + QString _S1 = QString("%1").arg(_A1 ).prepend("A" ); + QString _S2 = QString("%1").arg(_A1 ).prepend("Ma" ); + QString _S3 = QString("%1").arg(10*2+2 ).append ("leh" ); + return encryptString(( QStringList() << _S1 << _S2 << _S3 ).join('.')); +} Index: sources/view/settings/VSettings.h =================================================================== diff -u -r7c86f3854db9ad02d95681203198d75a0d65c9fa -r7ec98d237f871e5d1206809d309da6d57a086d28 --- sources/view/settings/VSettings.h (.../VSettings.h) (revision 7c86f3854db9ad02d95681203198d75a0d65c9fa) +++ sources/view/settings/VSettings.h (.../VSettings.h) (revision 7ec98d237f871e5d1206809d309da6d57a086d28) @@ -63,6 +63,8 @@ PROPERTY(QStringList , categorys , {} ) PROPERTY(QVariantMap , instructions , {} ) + PROPERTY(bool , isPasswordSet , false ) + SETTINGS(QString , servicePass , "" , Storage::Settings_Category_SettingsSystem , "Service" , "Password" ) SETTINGS(quint8 , alarmVolume , 5 , Storage::Settings_Category_SettingsSystem , "Alarm" , "Volume" ) SETTINGS(bool , roWaterMode , false , Storage::Settings_Category_SettingsSystem , "RoWaterMode" , "RoWaterMode" ) @@ -75,7 +77,9 @@ void updateInstructions ( const QString &vGroup, const TKeysList &vKeysList, const QVariantList &vValues ); void updateInstructions ( const QString &vGroup ); - QString encryptString (const QString &vString ); + QString encryptString (const QString &vString ); + QString defaultPassword (); + bool isPasswordDefault (); public slots: bool isPasswordValid (const QString &vPassword);