Commit b9873a89 authored by Karel Slaný's avatar Karel Slaný

Removed some function from the Accounts interface.

parent ccfa3c7c
......@@ -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)
{
......
......@@ -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 enveiroment.
* @param[in] isTestAccount True if account is ISDS test environment.
* @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 enveiroment.
* @param[in] isTestAccount True if account is ISDS test environment.
* @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.
*
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment