Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Datovka projects
mobile Datovka
Commits
b9873a89
Commit
b9873a89
authored
Nov 15, 2018
by
Karel Slaný
Browse files
Removed some function from the Accounts interface.
parent
ccfa3c7c
Changes
2
Hide whitespace changes
Inline
Side-by-side
src/accounts.cpp
View file @
b9873a89
...
...
@@ -470,6 +470,76 @@ bool boxMatchesUser(const QString &dbId, const QString &username)
return
dbId
==
GlobInstcs
::
accountDbPtr
->
dbId
(
username
);
}
/*!
* @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 on success.
*/
static
bool
changeFileDbName
(
const
QString
&
oldUserName
,
const
QString
&
newUserName
,
bool
storeToDisk
,
QString
&
errTxt
)
{
debugFuncCall
();
FileDb
*
fDb
=
GlobInstcs
::
fileDbsPtr
->
accessFileDb
(
GlobInstcs
::
setPtr
->
dbsLocation
,
oldUserName
,
storeToDisk
);
if
(
Q_UNLIKELY
(
fDb
==
Q_NULLPTR
))
{
errTxt
=
Accounts
::
tr
(
"Cannot access file database for the user name '%1'."
)
.
arg
(
oldUserName
);
return
false
;
}
/* Rename file database */
QString
currentDbFileName
=
fDb
->
fileName
();
currentDbFileName
.
replace
(
oldUserName
,
newUserName
);
if
(
!
fDb
->
moveDb
(
currentDbFileName
))
{
errTxt
=
Accounts
::
tr
(
"Cannot change file database on the user name '%1'."
)
.
arg
(
newUserName
);
return
false
;
}
return
true
;
}
/*!
* @brief Change message database name to new user name.
*
* @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.
*/
static
bool
changeMessageDbName
(
const
QString
&
oldUserName
,
const
QString
&
newUserName
,
bool
storeToDisk
,
QString
&
errTxt
)
{
debugFuncCall
();
MessageDb
*
msgDb
=
GlobInstcs
::
messageDbsPtr
->
accessMessageDb
(
GlobInstcs
::
setPtr
->
dbsLocation
,
oldUserName
,
storeToDisk
);
if
(
Q_UNLIKELY
(
msgDb
==
Q_NULLPTR
))
{
errTxt
=
Accounts
::
tr
(
"Cannot access message database for user name '%1'."
)
.
arg
(
oldUserName
);
return
false
;
}
/* Rename message database */
QString
currentDbFileName
=
msgDb
->
fileName
();
currentDbFileName
.
replace
(
oldUserName
,
newUserName
);
if
(
!
msgDb
->
moveDb
(
currentDbFileName
))
{
errTxt
=
Accounts
::
tr
(
"Cannot change message database on the user name '%1'."
)
.
arg
(
newUserName
);
return
false
;
}
return
true
;
}
bool
Accounts
::
changeAccountUserName
(
const
QVariant
&
acntModelVariant
,
const
QString
&
acntName
,
const
QString
&
newUserName
,
bool
storeToDisk
,
const
QString
&
oldUserName
,
const
QString
&
newDbId
)
...
...
@@ -564,54 +634,6 @@ exit:
return
false
;
}
bool
Accounts
::
changeFileDbName
(
const
QString
&
oldUserName
,
const
QString
&
newUserName
,
bool
storeToDisk
,
QString
&
errTxt
)
{
debugFuncCall
();
FileDb
*
fDb
=
GlobInstcs
::
fileDbsPtr
->
accessFileDb
(
GlobInstcs
::
setPtr
->
dbsLocation
,
oldUserName
,
storeToDisk
);
if
(
Q_UNLIKELY
(
fDb
==
Q_NULLPTR
))
{
errTxt
=
tr
(
"Cannot access file database for the user name '%1'."
).
arg
(
oldUserName
);
return
false
;
}
/* Rename file database */
QString
currentDbFileName
=
fDb
->
fileName
();
currentDbFileName
.
replace
(
oldUserName
,
newUserName
);
if
(
!
fDb
->
moveDb
(
currentDbFileName
))
{
errTxt
=
tr
(
"Cannot change file database on the user name '%1'."
).
arg
(
newUserName
);
return
false
;
}
return
true
;
}
bool
Accounts
::
changeMessageDbName
(
const
QString
&
oldUserName
,
const
QString
&
newUserName
,
bool
storeToDisk
,
QString
&
errTxt
)
{
debugFuncCall
();
MessageDb
*
msgDb
=
GlobInstcs
::
messageDbsPtr
->
accessMessageDb
(
GlobInstcs
::
setPtr
->
dbsLocation
,
oldUserName
,
storeToDisk
);
if
(
Q_UNLIKELY
(
msgDb
==
Q_NULLPTR
))
{
errTxt
=
tr
(
"Cannot access message database for user name '%1'."
)
.
arg
(
oldUserName
);
return
false
;
}
/* Rename message database */
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
);
return
false
;
}
return
true
;
}
void
Accounts
::
deleteAccountFromModel
(
AccountListModel
*
accountModel
,
const
QString
&
userName
)
{
...
...
src/accounts.h
View file @
b9873a89
...
...
@@ -157,7 +157,7 @@ public:
* @param[in] acntName Account name.
* @param[in] newUserName New user name identifying account.
* @param[in] pwd Password.
* @param[in] isTestAccount True if account is
isds
test env
e
iroment.
* @param[in] isTestAccount True if account is
ISDS
test enviro
n
ment.
* @param[in] rememberPwd True if remember password.
* @param[in] storeToDisk True if database store to local storage.
* @param[in] certPath Certificate path (can be null).
...
...
@@ -195,7 +195,7 @@ signals:
* @param[in] userName User name identifying account.
* @param[in] loginMetod User name identifying account.
* @param[in] pwd Password.
* @param[in] isTestAccount True if account is
isds
test env
e
iroment.
* @param[in] isTestAccount True if account is
ISDS
test enviro
n
ment.
* @param[in] rememberPwd True if remember password.
* @param[in] storeToDisk True if database store to local storage.
* @param[in] certPath Certificate path (can be null).
...
...
@@ -212,32 +212,6 @@ signals:
void
removeIsdsCtx
(
QString
userName
);
private:
/*!
* @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 on success.
*/
static
bool
changeFileDbName
(
const
QString
&
oldUserName
,
const
QString
&
newUserName
,
bool
storeToDisk
,
QString
&
errTxt
);
/*!
* @brief Change message database name to new user name.
*
* @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.
*/
static
bool
changeMessageDbName
(
const
QString
&
oldUserName
,
const
QString
&
newUserName
,
bool
storeToDisk
,
QString
&
errTxt
);
/*!
* @brief Delete account from model.
*
...
...
Write
Preview
Supports
Markdown
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