Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
7
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Open sidebar
Datovka projects
mobile Datovka
Commits
a55ccb8f
Commit
a55ccb8f
authored
May 11, 2017
by
Karel Slaný
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Using GlobalSettingsQmlWrapper::saveAllSettings().
parent
c31b670d
Changes
9
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
59 additions
and
61 deletions
+59
-61
qml/pages/PageMenuAccount.qml
qml/pages/PageMenuAccount.qml
+3
-1
src/accounts.cpp
src/accounts.cpp
+4
-3
src/main.cpp
src/main.cpp
+1
-1
src/net/isds_wrapper.cpp
src/net/isds_wrapper.cpp
+23
-19
src/net/isds_wrapper.h
src/net/isds_wrapper.h
+2
-1
src/settings.cpp
src/settings.cpp
+2
-16
src/settings.h
src/settings.h
+0
-11
src/setwrapper.cpp
src/setwrapper.cpp
+13
-5
src/setwrapper.h
src/setwrapper.h
+11
-4
No files found.
qml/pages/PageMenuAccount.qml
View file @
a55ccb8f
...
...
@@ -163,7 +163,9 @@ Component {
}
else
if
(
index
==
2
)
{
files
.
deleteFileDb
(
userName
)
}
else
if
(
index
==
3
)
{
isds
.
changePassword
(
userName
,
acntName
)
if
(
isds
.
changePassword
(
userName
,
acntName
))
{
settings
.
saveAllSettings
()
}
}
else
if
(
index
==
4
)
{
if
(
accounts
.
removeAccount
(
accountListModel
,
userName
,
true
))
{
pageView
.
pop
(
StackView
.
Immediate
)
...
...
src/accounts.cpp
View file @
a55ccb8f
...
...
@@ -30,6 +30,7 @@
#include "src/net/isds_wrapper.h"
#include "src/net/isds_session.h"
#include "src/settings.h"
#include "src/setwrapper.h"
#include "src/sqlite/account_db.h"
#include "src/models/accountmodel.h"
#include "src/sqlite/message_db_container.h"
...
...
@@ -167,7 +168,7 @@ bool Accounts::removeAccount(const QVariant &acntModelVariant,
/* Delete account from settings */
accountModel
->
deleteAccount
(
userName
);
saveAllSettings
();
GlobalSettingsQmlWrapper
::
saveAllSettings
();
return
true
;
}
...
...
@@ -254,7 +255,7 @@ void Accounts::updateAccount(const QVariant &acntModelVariant,
emit
removeIsdsCtx
(
userName
);
/* update account data in settings */
saveAllSettings
();
GlobalSettingsQmlWrapper
::
saveAllSettings
();
}
bool
Accounts
::
createAccount
(
const
QVariant
&
acntModelVariant
,
...
...
@@ -310,7 +311,7 @@ bool Accounts::createAccount(const QVariant &acntModelVariant,
void
Accounts
::
saveAccountToSettings
(
void
)
/* ========================================================================= */
{
saveAllSettings
();
GlobalSettingsQmlWrapper
::
saveAllSettings
();
}
...
...
src/main.cpp
View file @
a55ccb8f
...
...
@@ -418,7 +418,7 @@ int main(int argc, char *argv[])
* The PIN was set/recovered or
* incomplete data to check/recover the PIN were supplied.
*/
saveAllSettings
();
GlobalSettingsQmlWrapper
::
saveAllSettings
();
}
delete
globAccountsModelPtr
;
...
...
src/net/isds_wrapper.cpp
View file @
a55ccb8f
...
...
@@ -28,6 +28,7 @@
#include "src/models/accountmodel.h"
#include "src/models/messagemodel.h"
#include "src/settings.h"
#include "src/setwrapper.h"
IsdsWrapper
::
IsdsWrapper
(
QObject
*
parent
)
:
QObject
(
parent
)
...
...
@@ -94,7 +95,7 @@ bool IsdsWrapper::syncSingleAccountReceived(const QVariant &acntModelVariant,
}
globSet
.
setLastUpdateToNow
();
saveAllSettings
();
GlobalSettingsQmlWrapper
::
saveAllSettings
();
if
(
globSet
.
downloadCompleteMsgs
)
{
MessageListModel
*
messageModel
=
...
...
@@ -161,6 +162,8 @@ bool IsdsWrapper::syncSingleAccountSent(const QVariant &acntModelVariant,
false
,
true
);
}
/* Don't store last update time when downloading sent messages. */
if
(
globSet
.
downloadCompleteMsgs
)
{
MessageListModel
*
messageModel
=
MessageListModel
::
fromVariant
(
msgModelVariant
);
...
...
@@ -302,7 +305,7 @@ void IsdsWrapper::getDeliveryInfo(const QString &userName, qint64 msgId)
}
}
void
IsdsWrapper
::
changePassword
(
const
QString
&
userName
,
bool
IsdsWrapper
::
changePassword
(
const
QString
&
userName
,
const
QString
&
accountName
)
{
qDebug
(
"%s()"
,
__func__
);
...
...
@@ -312,12 +315,12 @@ void IsdsWrapper::changePassword(const QString &userName,
if
(
userName
.
isEmpty
())
{
Dialogues
::
errorMessage
(
Dialogues
::
CRITICAL
,
tr
(
"Error"
),
errTxt
,
tr
(
"Internal error"
));
return
;
return
false
;
}
if
(
!
isLoggedToIsds
(
userName
,
errTxt
))
{
showLoginProblemDialog
(
userName
,
errTxt
);
return
;
return
false
;
}
bool
ok
;
...
...
@@ -326,7 +329,7 @@ void IsdsWrapper::changePassword(const QString &userName,
tr
(
"Enter new password for account
\n
'%1'"
).
arg
(
accountName
),
Dialogues
::
EM_NORMAL
,
QString
(),
tr
(
"Enter password"
),
&
ok
);
if
(
!
ok
)
{
return
;
return
false
;
}
if
(
!
isCorrectPassword
(
newPwd
))
{
Dialogues
::
errorMessage
(
Dialogues
::
CRITICAL
,
...
...
@@ -334,7 +337,7 @@ void IsdsWrapper::changePassword(const QString &userName,
tr
(
"Wrong password format for username '%1'."
).
arg
(
userName
),
tr
(
"The new password must contain at least 8 characters including "
"at least 1 number and at least 1 upper-case letter."
));
return
;
return
false
;
}
if
(
m_isdsSession
.
isdsCtxMap
[
userName
].
login_method
==
USERNAME_PWD_TOTP
)
{
...
...
@@ -345,7 +348,7 @@ void IsdsWrapper::changePassword(const QString &userName,
tr
(
"Do you want to send SMS code now?"
),
Dialogues
::
NO
|
Dialogues
::
YES
,
Dialogues
::
YES
);
if
(
msgResponse
==
Dialogues
::
NO
)
{
return
;
return
false
;
}
if
(
!
m_xmlLayer
.
isdsSendSMS
(
m_isdsSession
.
isdsCtxMap
[
userName
]))
{
...
...
@@ -353,7 +356,7 @@ void IsdsWrapper::changePassword(const QString &userName,
tr
(
"Change password: %1"
).
arg
(
userName
),
tr
(
"Failed to send SMS code for username '%1'."
).
arg
(
userName
),
m_isdsSession
.
isdsCtxMap
[
userName
].
last_isds_msg
);
return
;
return
false
;
}
QString
text
=
Dialogues
::
getText
(
Q_NULLPTR
,
...
...
@@ -364,7 +367,7 @@ void IsdsWrapper::changePassword(const QString &userName,
if
(
ok
&&
!
text
.
isEmpty
())
{
m_isdsSession
.
isdsCtxMap
[
userName
].
pass_phrase
=
text
;
}
else
{
return
;
return
false
;
}
}
else
if
(
m_isdsSession
.
isdsCtxMap
[
userName
].
login_method
==
USERNAME_PWD_HOTP
)
{
...
...
@@ -376,7 +379,7 @@ void IsdsWrapper::changePassword(const QString &userName,
if
(
ok
&&
!
text
.
isEmpty
())
{
m_isdsSession
.
isdsCtxMap
[
userName
].
pass_phrase
=
text
;
}
else
{
return
;
return
false
;
}
}
...
...
@@ -389,17 +392,18 @@ void IsdsWrapper::changePassword(const QString &userName,
tr
(
"Change password: %1"
).
arg
(
userName
),
tr
(
"Failed to change password for username '%1'."
).
arg
(
userName
),
m_isdsSession
.
isdsCtxMap
[
userName
].
last_isds_msg
);
}
else
{
emit
statusBarTextChanged
(
m_isdsSession
.
isdsCtxMap
[
userName
].
last_isds_msg
,
false
,
true
);
return
false
;
}
m_isdsSession
.
removeIsdsCtx
(
userName
);
emit
statusBarTextChanged
(
m_isdsSession
.
isdsCtxMap
[
userName
].
last_isds_msg
,
false
,
true
);
AcntData
&
acntData
(
AccountListModel
::
globAccounts
[
userName
]);
acntData
.
setPassword
(
newPwd
);
saveAllSettings
();
}
m_isdsSession
.
removeIsdsCtx
(
userName
);
AcntData
&
acntData
(
AccountListModel
::
globAccounts
[
userName
]);
acntData
.
setPassword
(
newPwd
);
return
true
;
}
bool
IsdsWrapper
::
isLoggedToIsdsOtp
(
const
QString
&
userName
)
...
...
src/net/isds_wrapper.h
View file @
a55ccb8f
...
...
@@ -130,7 +130,8 @@ public:
* @param[in] accountName Account name.
*/
Q_INVOKABLE
void
changePassword
(
const
QString
&
userName
,
const
QString
&
accountName
);
bool
changePassword
(
const
QString
&
userName
,
const
QString
&
accountName
);
/*!
* @brief Test if user is connected to databox via OTP.
...
...
src/settings.cpp
View file @
a55ccb8f
...
...
@@ -34,8 +34,7 @@
Settings
globSet
;
Settings
::
Settings
(
void
)
:
language
(
LANGUAGE_SYSTEM
),
:
language
(
LANGUAGE_SYSTEM
),
fontSize
(
DEFAULT_FONT_SIZE
),
downloadOnlyNewMsgs
(
true
),
downloadCompleteMsgs
(
false
),
...
...
@@ -46,15 +45,11 @@ Settings::Settings(void)
pinSalt
(),
pinCode
(),
pinInactTimeoutInSecs
(
DEFAULT_PIN_INACT_TIMEOUT
),
dbsLocation
(
""
),
dbsLocation
(),
m_lastUpdate
()
{
}
Settings
::~
Settings
(
void
)
{
}
void
Settings
::
saveToSettings
(
QSettings
&
settings
)
const
{
qDebug
(
"%s()"
,
__func__
);
...
...
@@ -200,12 +195,3 @@ QString Settings::lastUpdateStr(void) const
}
#undef DATE_FMT
}
void
saveAllSettings
(
void
)
{
QSettings
settings
(
Settings
::
settingsPath
(),
QSettings
::
IniFormat
);
settings
.
clear
();
globSet
.
saveToSettings
(
settings
);
globAccountsModelPtr
->
saveAccountsToSettings
(
globSet
.
_pinVal
,
settings
);
settings
.
sync
();
}
src/settings.h
View file @
a55ccb8f
...
...
@@ -66,11 +66,6 @@ public:
*/
Settings
(
void
);
/*!
* @brief Destructor.
*/
~
Settings
(
void
);
/*!
* @brief Load data from supplied settings.
*
...
...
@@ -133,15 +128,9 @@ private:
QString
m_lastUpdate
;
};
/*!
* @brief Global instance of the structure.
*/
extern
Settings
globSet
;
/*!
* @brief Reads all settings and stores them into configuration file.
*/
void
saveAllSettings
(
void
);
#endif // SETTINGS_H
src/setwrapper.cpp
View file @
a55ccb8f
...
...
@@ -21,7 +21,6 @@
* the two.
*/
#include <QtDebug> // qCritical
#include <QFileDialog>
#include "src/crypto/pin.h"
...
...
@@ -29,8 +28,8 @@
#include "src/dialogues/dialogues.h"
#include "src/models/accountmodel.h"
#include "src/io/filesystem.h"
#include "src/setwrapper.h"
#include "src/settings.h"
#include "src/setwrapper.h"
GlobalSettingsQmlWrapper
::
GlobalSettingsQmlWrapper
(
QObject
*
parent
)
:
QObject
(
parent
)
...
...
@@ -190,8 +189,8 @@ void GlobalSettingsQmlWrapper::verifyPin(const QString &pinValue)
{
if
(
globSet
.
pinAlg
.
isEmpty
()
||
globSet
.
pinSalt
.
isEmpty
()
||
globSet
.
pinCode
.
isEmpty
())
{
qCritical
(
)
<<
"PIN algorithm, PIN salt or encoded PIN are missing."
;
qCritical
(
"%s"
,
"PIN algorithm, PIN salt or encoded PIN are missing."
)
;
return
;
}
...
...
@@ -200,7 +199,7 @@ void GlobalSettingsQmlWrapper::verifyPin(const QString &pinValue)
if
(
verResult
)
{
/* Remember entered correct PIN. */
globSet
.
_pinVal
=
pinValue
;
qDebug
(
)
<<
"Remembering entered PIN value."
;
qDebug
(
"%s"
,
"Remembering entered PIN value."
)
;
/* Decrypt all keys in account model. */
AccountListModel
::
decryptAllPwds
(
globSet
.
_pinVal
);
...
...
@@ -291,3 +290,12 @@ void GlobalSettingsQmlWrapper::setInactivityInterval(int secs)
{
globSet
.
pinInactTimeoutInSecs
=
(
secs
>
0
)
?
secs
:
0
;
}
void
GlobalSettingsQmlWrapper
::
saveAllSettings
(
void
)
{
QSettings
settings
(
Settings
::
settingsPath
(),
QSettings
::
IniFormat
);
settings
.
clear
();
globSet
.
saveToSettings
(
settings
);
globAccountsModelPtr
->
saveAccountsToSettings
(
globSet
.
_pinVal
,
settings
);
settings
.
sync
();
}
src/setwrapper.h
View file @
a55ccb8f
...
...
@@ -21,10 +21,11 @@
* the two.
*/
#ifndef SETWRAPPER_H
#define SETWRAPPER_H
#ifndef
_
SETWRAPPER_H
_
#define
_
SETWRAPPER_H
_
#include <QObject>
#include <QString>
/*
* This class provide wrapper between
...
...
@@ -39,7 +40,7 @@ public:
/*!
* @brief Constructor.
*/
GlobalSettingsQmlWrapper
(
QObject
*
parent
=
Q_NULLPTR
);
GlobalSettingsQmlWrapper
(
QObject
*
parent
=
Q_NULLPTR
);
/*!
* @brief Get application version string.
...
...
@@ -153,6 +154,12 @@ public:
Q_INVOKABLE
void
setInactivityInterval
(
int
secs
);
/*!
* @brief Gathers all settings and stores them into configuration file.
*/
Q_INVOKABLE
static
void
saveAllSettings
(
void
);
signals:
/*!
* @brief Send current general settings to QML.
...
...
@@ -219,4 +226,4 @@ signals:
void
saveSettingsStorageResponse
(
void
);
};
#endif /
/
SETWRAPPER_H
#endif
/
* _
SETWRAPPER_H
_ */
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment