Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
mobile Datovka
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
14
Issues
14
List
Boards
Labels
Service Desk
Milestones
Merge Requests
4
Merge Requests
4
Operations
Operations
Incidents
Packages & Registries
Packages & Registries
Container Registry
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Datovka projects
mobile Datovka
Commits
ccfa3c7c
Commit
ccfa3c7c
authored
Nov 15, 2018
by
Karel Slaný
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Modification in interface of Accounts.
parent
a26a343d
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
47 additions
and
37 deletions
+47
-37
src/accounts.cpp
src/accounts.cpp
+41
-23
src/accounts.h
src/accounts.h
+6
-14
No files found.
src/accounts.cpp
View file @
ccfa3c7c
...
...
@@ -146,6 +146,18 @@ void Accounts::getAccountData(const QString &userName)
acntData
.
rememberPwd
(),
acntData
.
storeToDisk
(),
acntData
.
certPath
());
}
/*!
* @brief Check if username has correct length.
*
* @param[in] username Account login.
* @return True if length is correct.
*/
static
bool
usernameCorrectLength
(
const
QString
&
userName
)
{
return
userName
.
length
()
==
6
;
}
bool
Accounts
::
createAccount
(
const
QVariant
&
acntModelVariant
,
const
QString
&
loginMetod
,
const
QString
&
acntName
,
const
QString
&
userName
,
const
QString
&
pwd
,
bool
isTestAccount
,
bool
rememberPwd
,
bool
storeToDisk
,
...
...
@@ -170,7 +182,7 @@ bool Accounts::createAccount(const QVariant &acntModelVariant,
goto
fail
;
}
if
(
!
hasCorrectLengthUserName
(
newUserName
))
{
if
(
!
usernameCorrectLength
(
newUserName
))
{
errTxt
=
tr
(
"User name '%1' has wrong length."
).
arg
(
newUserName
);
goto
fail
;
}
...
...
@@ -484,14 +496,15 @@ bool Accounts::changeAccountUserName(const QVariant &acntModelVariant,
/* Check if new user name corresponds with data box id. */
if
(
!
boxMatchesUser
(
newDbId
,
oldUserName
))
{
errTxt
=
tr
(
"New data box identifier '%1' does not correspond with the
user
name '%2'."
)
.
arg
(
newDbId
).
arg
(
new
UserName
);
errTxt
=
tr
(
"New data box identifier '%1' does not correspond with the
old user
name '%2'."
)
.
arg
(
newDbId
).
arg
(
old
UserName
);
goto
fail
;
}
/* First: Change user name in the account database (user_info, account_info) */
if
(
!
GlobInstcs
::
accountDbPtr
->
changeUserName
(
oldUserName
,
newUserName
))
{
errTxt
=
tr
(
"Cannot change user name '%1' in the account database."
).
arg
(
newUserName
);
errTxt
=
tr
(
"Cannot change username '%1' in the account database."
)
.
arg
(
newUserName
);
goto
fail
;
}
...
...
@@ -508,12 +521,13 @@ bool Accounts::changeAccountUserName(const QVariant &acntModelVariant,
/* Last: Delete original/old account from model and settings */
deleteAccountFromModel
(
accountModel
,
oldUserName
);
logInfoNL
(
"Username has been changed
on
'%s'."
,
logInfoNL
(
"Username has been changed
to
'%s'."
,
newUserName
.
toUtf8
().
constData
());
Dialogues
::
errorMessage
(
Dialogues
::
INFORMATION
,
tr
(
"Change user name: %1"
).
arg
(
oldUserName
),
tr
(
"The new user name '%1' for account '%2' has been set."
).
arg
(
newUserName
).
arg
(
acntName
),
tr
(
"A new user name '%1' for the account '%2' has been set."
)
.
arg
(
newUserName
).
arg
(
acntName
),
tr
(
"Account will use the new settings."
));
return
true
;
...
...
@@ -522,23 +536,26 @@ rollbackFilesChanges:
/* Change back file database name */
if
(
changeFileDbName
(
newUserName
,
oldUserName
,
storeToDisk
,
errTxt
))
{
logErrorNL
(
"Cannot
change back file database name %s
."
,
logErrorNL
(
"Cannot
restore file database name '%s'
."
,
oldUserName
.
toUtf8
().
constData
());
}
rollbackAccountChanges:
/* Change back origi
al user name in the account database
*/
/* Change back origi
nal user name in the account database.
*/
if
(
!
GlobInstcs
::
accountDbPtr
->
changeUserName
(
newUserName
,
oldUserName
))
{
logErrorNL
(
"%s"
,
"Cannot change back user name in the account database."
);
logErrorNL
(
"%s"
,
"Cannot restore user name in the account database."
);
}
fail:
/* Show error dialog with message what happened */
/* Show error dialog
ue
with message what happened */
Dialogues
::
errorMessage
(
Dialogues
::
CRITICAL
,
tr
(
"User name problem: %1"
).
arg
(
oldUserName
),
tr
(
"The new user name '%1' for account '%2' has not been set!"
).
arg
(
newUserName
).
arg
(
acntName
),
errTxt
+
" "
+
tr
(
"Account will use the original settings."
));
tr
(
"The new user name '%1' for account '%2' has not been set!"
)
.
arg
(
newUserName
).
arg
(
acntName
),
errTxt
+
QStringLiteral
(
" "
)
+
tr
(
"Account will use the original settings."
));
exit:
/* Remove new account */
...
...
@@ -554,7 +571,7 @@ bool Accounts::changeFileDbName(const QString &oldUserName,
FileDb
*
fDb
=
GlobInstcs
::
fileDbsPtr
->
accessFileDb
(
GlobInstcs
::
setPtr
->
dbsLocation
,
oldUserName
,
storeToDisk
);
if
(
fDb
==
Q_NULLPTR
)
{
if
(
Q_UNLIKELY
(
fDb
==
Q_NULLPTR
)
)
{
errTxt
=
tr
(
"Cannot access file database for the user name '%1'."
).
arg
(
oldUserName
);
return
false
;
}
...
...
@@ -577,8 +594,9 @@ bool Accounts::changeMessageDbName(const QString &oldUserName,
MessageDb
*
msgDb
=
GlobInstcs
::
messageDbsPtr
->
accessMessageDb
(
GlobInstcs
::
setPtr
->
dbsLocation
,
oldUserName
,
storeToDisk
);
if
(
msgDb
==
Q_NULLPTR
)
{
errTxt
=
tr
(
"Cannot access message database for user name '%1'."
).
arg
(
oldUserName
);
if
(
Q_UNLIKELY
(
msgDb
==
Q_NULLPTR
))
{
errTxt
=
tr
(
"Cannot access message database for user name '%1'."
)
.
arg
(
oldUserName
);
return
false
;
}
...
...
@@ -586,25 +604,25 @@ bool Accounts::changeMessageDbName(const QString &oldUserName,
QString
currentDbFileName
=
msgDb
->
fileName
();
currentDbFileName
.
replace
(
oldUserName
,
newUserName
);
if
(
!
msgDb
->
moveDb
(
currentDbFileName
))
{
errTxt
=
tr
(
"Cannot change message database on the user name '%1'."
).
arg
(
newUserName
);
errTxt
=
tr
(
"Cannot change message database on the user name '%1'."
)
.
arg
(
newUserName
);
return
false
;
}
return
true
;
}
bool
Accounts
::
hasCorrectLengthUserName
(
const
QString
&
userName
)
{
/* Check if new user name has correct length */
return
(
userName
.
length
()
==
6
);
}
void
Accounts
::
deleteAccountFromModel
(
AccountListModel
*
accountModel
,
const
QString
&
userName
)
{
if
(
Q_UNLIKELY
((
accountModel
==
Q_NULLPTR
)
||
userName
.
isEmpty
()))
{
Q_ASSERT
(
0
);
return
;
}
/* Remove old account from model */
accountModel
->
deleteAccount
(
userName
);
/* Delete
isds
session context of old account */
/* Delete
ISDS
session context of old account */
emit
removeIsdsCtx
(
userName
);
/* Load message counters of all accounts */
loadModelCounters
(
accountModel
);
...
...
src/accounts.h
View file @
ccfa3c7c
...
...
@@ -205,23 +205,23 @@ signals:
bool
rememberPwd
,
bool
storeToDisk
,
QString
certPath
);
/*!
* @brief Remove
isds context for account in the isds
session.
* @brief Remove
ISDS context for account in the ISDS
session.
*
* @param[in]
acntName Account
name.
* @param[in]
userName User
name.
*/
void
removeIsdsCtx
(
QString
userName
);
private:
/*!
* @brief Change file database name to new user
name.
* @brief Change file database name to new username.
*
* @param[in] oldUserName Original user name of account.
* @param[in] newUserName New user name identifying account.
* @param[in] storeToDisk True if database store to local storage.
* @param[out] errTxt Error description.
* @return True
if
success.
* @return True
on
success.
*/
static
bool
changeFileDbName
(
const
QString
&
oldUserName
,
const
QString
&
newUserName
,
bool
storeToDisk
,
QString
&
errTxt
);
...
...
@@ -234,18 +234,10 @@ private:
* @param[out] errTxt Error description.
* @return True if success.
*/
static
bool
changeMessageDbName
(
const
QString
&
oldUserName
,
const
QString
&
newUserName
,
bool
storeToDisk
,
QString
&
errTxt
);
/*!
* @brief Check if user name has correct length.
*
* @param[in] userName New user name identifying account.
* @return True if length is correct.
*/
static
bool
hasCorrectLengthUserName
(
const
QString
&
userName
);
/*!
* @brief Delete account from model.
*
...
...
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