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

Merge branch 'change-account-username' into 'develop'

Allow to Change Account Username

See merge request !132
parents 7233124f 754b4199
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
* *
* This program is distributed in the hope that it will be useful, * This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
...@@ -39,6 +39,7 @@ Item { ...@@ -39,6 +39,7 @@ Item {
property bool isNewAccount: (userName == "") property bool isNewAccount: (userName == "")
property string sLoginMethod: "pwd" property string sLoginMethod: "pwd"
property string oldUserName
Component.onCompleted: { Component.onCompleted: {
if (!isNewAccount) { if (!isNewAccount) {
...@@ -95,14 +96,28 @@ Item { ...@@ -95,14 +96,28 @@ Item {
isds.doIsdsAction("addNewAccount", userNameTextField.text.toString()) isds.doIsdsAction("addNewAccount", userNameTextField.text.toString())
} }
} else { } else {
// Update account context data. // Change account user name.
if (accounts.updateAccount(accountModel, sLoginMethod, if (userNameTextField.text.toString() !== oldUserName) {
accountNameTextField.text.toString(), // Create temporary account with a new user name.
userNameTextField.text.toString(), if (accounts.prepareChangeUserName(accountModel, sLoginMethod,
passwordTextField.text.toString(), accountNameTextField.text.toString(),
testAccount.checked, rememberPassword.checked, userNameTextField.text.toString(),
useLS.checked, certPathLabelId.text.toString())) { passwordTextField.text.toString(),
settings.saveAllSettings(accountModel) testAccount.checked, rememberPassword.checked,
useLS.checked, certPathLabelId.text.toString(), oldUserName)) {
// Login to isds with the new user name.
isds.doIsdsAction("changeUserName", userNameTextField.text.toString())
}
} else {
// Update account context data.
if (accounts.updateAccount(accountModel, sLoginMethod,
accountNameTextField.text.toString(),
userNameTextField.text.toString(),
passwordTextField.text.toString(),
testAccount.checked, rememberPassword.checked,
useLS.checked, certPathLabelId.text.toString())) {
settings.saveAllSettings(accountModel)
}
} }
pageView.pop(StackView.Immediate) pageView.pop(StackView.Immediate)
} }
...@@ -114,24 +129,28 @@ Item { ...@@ -114,24 +129,28 @@ Item {
settings.saveAllSettings(accountModel) settings.saveAllSettings(accountModel)
pageView.pop(StackView.Immediate) pageView.pop(StackView.Immediate)
} }
}
Connections {
// Connection is activated when login to new account fails.
target: isds
onUnsuccessedLoginToIsdsSig: { onUnsuccessedLoginToIsdsSig: {
if (accounts.removeAccount(accountModel, userName, false)) { if (accounts.removeAccount(accountModel, userName, false)) {
settings.saveAllSettings(accountModel) settings.saveAllSettings(accountModel)
} }
} }
}
Connections {
// Connection is activated when login phase was succeeded and
// try download account info.
target: isds
onRunGetAccountInfoSig: { onRunGetAccountInfoSig: {
settings.saveAllSettings(accountModel) settings.saveAllSettings(accountModel)
isds.getAccountInfo(userName) isds.getAccountInfo(userName)
} }
onRunChangeUserNameSig: {
// Login to isds with new user name has been succeeded.
// Get databox ID of new user name.
var dbId = isds.getAccountDbId(userName)
// Change username and rename databases.
if (accounts.changeAccountUserName(accountModel,
accountNameTextField.text.toString(),
userNameTextField.text.toString(),
useLS.checked, oldUserName, dbId)) {
settings.saveAllSettings(accountModel)
isds.getAccountInfo(userName)
}
}
} }
} }
} }
...@@ -173,7 +192,7 @@ Item { ...@@ -173,7 +192,7 @@ Item {
if (sLoginMethod === "cert") { if (sLoginMethod === "cert") {
certificateLabel.visible = true certificateLabel.visible = true
certPathButtonId.visible = true certPathButtonId.visible = true
certPathLabelId.visible = (certPathLabelId.text != "") certPathLabelId.visible = (certPathLabelId.text !== "")
} else { } else {
certificateLabel.visible = false certificateLabel.visible = false
certPathLabelId.visible = false certPathLabelId.visible = false
...@@ -318,7 +337,7 @@ Item { ...@@ -318,7 +337,7 @@ Item {
useLS.checked = storeToDisk useLS.checked = storeToDisk
certPathLabelId.text = certPath certPathLabelId.text = certPath
loginMethodComboBox.selectCurrentKey(loginMethod) loginMethodComboBox.selectCurrentKey(loginMethod)
userNameTextField.enabled = false oldUserName = userName
testAccount.enabled = false testAccount.enabled = false
headerBar.title = qsTr("Account settings") headerBar.title = qsTr("Account settings")
} }
......
This diff is collapsed.
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
* *
* This program is distributed in the hope that it will be useful, * This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
...@@ -149,6 +149,44 @@ public: ...@@ -149,6 +149,44 @@ public:
static static
void loadModelCounters(AccountListModel *accountModel); void loadModelCounters(AccountListModel *accountModel);
/*!
* @brief Prepare change account user name.
*
* @param[in,out] acntModelVariant QVariant holding account model.
* @param[in] loginMetod User name identifying account.
* @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 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).
* @param[in] oldUserName Original old user name of account.
* @return True if success.
*/
Q_INVOKABLE
bool prepareChangeUserName(const QVariant &acntModelVariant,
const QString &loginMetod, const QString &acntName,
const QString &newUserName, const QString &pwd, bool isTestAccount,
bool rememberPwd, bool storeToDisk, const QString &certPath,
const QString &oldUserName);
/*!
* @brief Change account user name and store account to settings.
*
* @param[in,out] acntModelVariant QVariant holding account model.
* @param[in] acntName Account name.
* @param[in] newUserName New user name identifying account.
* @param[in] storeToDisk True if database store to local storage.
* @param[in] oldUserName Original user name of account.
* @param[in] newDbId Databox id of new user name.
* @return True if success.
*/
Q_INVOKABLE
bool changeAccountUserName(const QVariant &acntModelVariant,
const QString &acntName, const QString &newUserName,
bool storeToDisk, const QString &oldUserName, const QString &newDbId);
signals: signals:
/*! /*!
* @brief Send account settings to QML settings page. * @brief Send account settings to QML settings page.
...@@ -157,7 +195,7 @@ signals: ...@@ -157,7 +195,7 @@ signals:
* @param[in] userName User name identifying account. * @param[in] userName User name identifying account.
* @param[in] loginMetod User name identifying account. * @param[in] loginMetod User name identifying account.
* @param[in] pwd Password. * @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] rememberPwd True if remember password.
* @param[in] storeToDisk True if database store to local storage. * @param[in] storeToDisk True if database store to local storage.
* @param[in] certPath Certificate path (can be null). * @param[in] certPath Certificate path (can be null).
...@@ -167,9 +205,19 @@ signals: ...@@ -167,9 +205,19 @@ signals:
bool rememberPwd, bool storeToDisk, QString certPath); 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); void removeIsdsCtx(QString userName);
private:
/*!
* @brief Delete account from model.
*
* @param[in,out] accountModel Model whose counters should be updated.
* @param[in] userName User name identifying account.
*/
void deleteAccountFromModel(AccountListModel *accountModel,
const QString &userName);
}; };
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
* *
* This program is distributed in the hope that it will be useful, * This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
......
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
* *
* This program is distributed in the hope that it will be useful, * This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
...@@ -727,24 +727,25 @@ void AccountListModel::saveAccountsToSettings(const QString &pinVal, ...@@ -727,24 +727,25 @@ void AccountListModel::saveAccountsToSettings(const QString &pinVal,
} }
} }
int AccountListModel::addAccount(const AcntData &acntData, QModelIndex *idx) enum AccountListModel::AddAcntResult AccountListModel::addAccount(
const AcntData &acntData, QModelIndex *idx)
{ {
if (Q_UNLIKELY(m_accountsPtr == Q_NULLPTR)) { if (Q_UNLIKELY(m_accountsPtr == Q_NULLPTR)) {
Q_ASSERT(0); Q_ASSERT(0);
return -1; return AA_ERR;
} }
const QString userName(acntData.userName()); const QString userName(acntData.userName());
if (userName.isEmpty()) { if (userName.isEmpty()) {
Q_ASSERT(0); Q_ASSERT(0);
return -1; return AA_ERR;
} }
if (m_accountsPtr->contains(userName)) { if (m_accountsPtr->contains(userName)) {
logWarningNL("Account with username '%s' already exists.", logWarningNL("Account with username '%s' already exists.",
userName.toUtf8().constData()); userName.toUtf8().constData());
return -2; return AA_EXISTS;
} }
Q_ASSERT(!m_userNames.contains(userName)); Q_ASSERT(!m_userNames.contains(userName));
...@@ -761,7 +762,7 @@ int AccountListModel::addAccount(const AcntData &acntData, QModelIndex *idx) ...@@ -761,7 +762,7 @@ int AccountListModel::addAccount(const AcntData &acntData, QModelIndex *idx)
*idx = index(m_userNames.size() - 1, 0, QModelIndex()); *idx = index(m_userNames.size() - 1, 0, QModelIndex());
} }
return 0; return AA_SUCCESS;
} }
void AccountListModel::deleteAccount(const QString &userName) void AccountListModel::deleteAccount(const QString &userName)
......
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
* *
* This program is distributed in the hope that it will be useful, * This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
...@@ -152,6 +152,15 @@ public: ...@@ -152,6 +152,15 @@ public:
}; };
Q_ENUM(Roles) Q_ENUM(Roles)
/*!
* @brief Return add account result.
*/
enum AddAcntResult {
AA_SUCCESS = 0, /*!< Operation was successful. */
AA_EXISTS, /*!< Account already exists in the model. */
AA_ERR /*!< Internal error. */
};
/* Don't forget to declare various properties to the QML system. */ /* Don't forget to declare various properties to the QML system. */
static static
void declareQML(void); void declareQML(void);
...@@ -239,12 +248,11 @@ public: ...@@ -239,12 +248,11 @@ public:
* @brief Add account. * @brief Add account.
* *
* @patam[in] acntSettings Settings data to be added into the model. * @patam[in] acntSettings Settings data to be added into the model.
* @param[out] idx Index of newly added account if specified. * @param[out] idx Index of newly added account if specified.
* @return -2 if account already exists, * @return Error state.
* -1 if account could not be added,
* 0 if account was added.
*/ */
int addAccount(const AcntData &acntData, QModelIndex *idx = Q_NULLPTR); enum AddAcntResult addAccount(const AcntData &acntData,
QModelIndex *idx = Q_NULLPTR);
/*! /*!
* @brief Delete account. * @brief Delete account.
......
...@@ -261,6 +261,8 @@ void IsdsWrapper::doIsdsAction(const QString &isdsAction, ...@@ -261,6 +261,8 @@ void IsdsWrapper::doIsdsAction(const QString &isdsAction,
emit runDownloadMessageSig(userName); emit runDownloadMessageSig(userName);
} else if (isdsAction == "addNewAccount") { } else if (isdsAction == "addNewAccount") {
emit runGetAccountInfoSig(userName); emit runGetAccountInfoSig(userName);
} else if (isdsAction == "changeUserName") {
emit runChangeUserNameSig(userName);
} else if (isdsAction == "getAccountInfo") { } else if (isdsAction == "getAccountInfo") {
emit runGetAccountInfoSig(userName); emit runGetAccountInfoSig(userName);
} else if (isdsAction == "syncOneAccount") { } else if (isdsAction == "syncOneAccount") {
...@@ -321,12 +323,46 @@ void IsdsWrapper::getAccountInfo(const QString &userName) ...@@ -321,12 +323,46 @@ void IsdsWrapper::getAccountInfo(const QString &userName)
arg(userName), true, true); arg(userName), true, true);
TaskDownloadAccountInfo *task; TaskDownloadAccountInfo *task;
/* Last param: true = store account info into database */
task = new (std::nothrow) TaskDownloadAccountInfo( task = new (std::nothrow) TaskDownloadAccountInfo(
m_isdsSession.isdsCtxMap[userName], &m_netLayer); m_isdsSession.isdsCtxMap[userName], &m_netLayer, true);
task->setAutoDelete(true); task->setAutoDelete(true);
GlobInstcs::workPoolPtr->assignHi(task); GlobInstcs::workPoolPtr->assignHi(task);
} }
QString IsdsWrapper::getAccountDbId(const QString &userName)
{
debugFuncCall();
if (Q_UNLIKELY(GlobInstcs::workPoolPtr == Q_NULLPTR)) {
Q_ASSERT(0);
return QString();
}
QString errTxt(tr("Wrong username"));
if (userName.isEmpty()) {
Dialogues::errorMessage(Dialogues::CRITICAL,
tr("Error"), errTxt, tr("Internal error"));
return QString();
}
/* User must be logged to isds */
if (!isLoggedToIsds(userName)) {
return QString();
}
TaskDownloadAccountInfo *task;
/* Last param: false = account info won't store into database */
task = new (std::nothrow) TaskDownloadAccountInfo(
m_isdsSession.isdsCtxMap[userName], &m_netLayer, false);
task->setAutoDelete(false);
GlobInstcs::workPoolPtr->runSingle(task);
QString dbId(task->m_dbID);
delete task; task = Q_NULLPTR;
return dbId;
}
int IsdsWrapper::findDataboxFulltext(const QString &userName, int IsdsWrapper::findDataboxFulltext(const QString &userName,
const QVariant &dbModelVariant, const QString &phrase, const QVariant &dbModelVariant, const QString &phrase,
const QString &searchType, const QString &searchScope, int page) const QString &searchType, const QString &searchScope, int page)
...@@ -516,7 +552,7 @@ bool IsdsWrapper::isCorrectPassword(const QString &password) ...@@ -516,7 +552,7 @@ bool IsdsWrapper::isCorrectPassword(const QString &password)
void IsdsWrapper::inputDialogCancelPostAction(const QString &isdsAction, void IsdsWrapper::inputDialogCancelPostAction(const QString &isdsAction,
const QString &userName) const QString &userName)
{ {
if (isdsAction == "addNewAccount") { if (isdsAction == "addNewAccount" || isdsAction == "changeUserName") {
emit unsuccessedLoginToIsdsSig(userName); emit unsuccessedLoginToIsdsSig(userName);
} }
} }
...@@ -1124,6 +1160,14 @@ void IsdsWrapper::doLoginAction(const QString &isdsAction, ...@@ -1124,6 +1160,14 @@ void IsdsWrapper::doLoginAction(const QString &isdsAction,
tr("ISDS returns:") + " " + m_isdsSession.isdsCtxMap[userName].last_isds_msg + "\n\n" + tr("ISDS returns:") + " " + m_isdsSession.isdsCtxMap[userName].last_isds_msg + "\n\n" +
tr("Check your login data and try again.")); tr("Check your login data and try again."));
emit unsuccessedLoginToIsdsSig(userName); emit unsuccessedLoginToIsdsSig(userName);
} else if (isdsAction == "changeUserName") {
Dialogues::errorMessage(Dialogues::CRITICAL,
tr("Username change: %1").arg(userName),
tr("Username could not be changed because an error occurred while trying to log in with new user name '%1'.")
.arg(userName),
tr("ISDS returns:") + " " + m_isdsSession.isdsCtxMap[userName].last_isds_msg + "\n\n" +
tr("Check your login data and try again."));
emit unsuccessedLoginToIsdsSig(userName);
} else { } else {
/* Show error login dialogue */ /* Show error login dialogue */
Dialogues::errorMessage(Dialogues::CRITICAL, Dialogues::errorMessage(Dialogues::CRITICAL,
......
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
* *
* This program is distributed in the hope that it will be useful, * This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
...@@ -130,6 +130,15 @@ public: ...@@ -130,6 +130,15 @@ public:
Q_INVOKABLE Q_INVOKABLE
void getAccountInfo(const QString &userName); void getAccountInfo(const QString &userName);
/*!
* @brief Get databox ID from ISDS.
*
* @param[in] userName Account username string.
* @return Return databox ID.
*/
Q_INVOKABLE
QString getAccountDbId(const QString &userName);
/*! /*!
* @brief Downloads delivery info. * @brief Downloads delivery info.
* *
...@@ -347,6 +356,13 @@ signals: ...@@ -347,6 +356,13 @@ signals:
*/ */
void downloadAccountInfoFinishedSig(QString userName); void downloadAccountInfoFinishedSig(QString userName);
/*!
* @brief Signal is emitted when account username can be changed.
*
* @param[in] userName Account user name string.
*/
void runChangeUserNameSig(QString userName);
/*! /*!
* @brief Run download mesasge isds action from QML. * @brief Run download mesasge isds action from QML.
* *
......
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
* *
* This program is distributed in the hope that it will be useful, * This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
...@@ -608,6 +608,56 @@ fail: ...@@ -608,6 +608,56 @@ fail:
return Isds::DbOwnerInfo(); return Isds::DbOwnerInfo();
} }
bool AccountDb::changeUserName(const QString &oldUserName,
const QString &newUserName)
{
QSqlQuery query(m_db);
QString queryStr;
if (!m_db.isOpen()) {
logErrorNL("%s", "Account database seems not to be open.");
goto fail;
}
beginTransaction();
queryStr = "UPDATE account_info "
"SET key = :newUserName WHERE key = :oldUserName";
if (!query.prepare(queryStr)) {
logErrorNL("Cannot prepare SQL query: %s",
query.lastError().text().toUtf8().constData());
goto fail;
}
query.bindValue(":oldUserName", oldUserName);
query.bindValue(":newUserName", newUserName);
if (!query.exec()) {
logErrorNL("Cannot execute SQL query: %s",
query.lastError().text().toUtf8().constData());
goto fail;
}
queryStr = "UPDATE user_info "
"SET key = :newUserName WHERE key = :oldUserName";
if (!query.prepare(queryStr)) {
logErrorNL("Cannot prepare SQL query: %s",
query.lastError().text().toUtf8().constData());
goto fail;
}
query.bindValue(":oldUserName", oldUserName);
query.bindValue(":newUserName", newUserName);
if (query.exec()) {
commitTransaction();
return true;
} else {
logErrorNL("Cannot execute SQL query: %s",
query.lastError().text().toUtf8().constData());
}
fail:
rollbackTransaction();
return false;
}
QList<class SQLiteTbl *> AccountDb::listOfTables(void) const QList<class SQLiteTbl *> AccountDb::listOfTables(void) const
{ {
QList<class SQLiteTbl *> tables; QList<class SQLiteTbl *> tables;
......
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
* *
* This program is distributed in the hope that it will be useful, * This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
...@@ -117,6 +117,16 @@ public: ...@@ -117,6 +117,16 @@ public:
*/ */
const Isds::DbOwnerInfo getOwnerInfo(const QString &key) const; const Isds::DbOwnerInfo getOwnerInfo(const QString &key) const;
/*!
* @brief Change user name in account db.
*
* @param[in] oldUserName Current account user name.
* @param[in] newUserName New account user name.
* @return True on success.
*/
bool changeUserName(const QString &oldUserName,
const QString &newUserName);
protected: protected:
/*! /*!
* @brief Returns list of tables. * @brief Returns list of tables.
......
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
* *
* This program is distributed in the hope that it will be useful, * This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
...@@ -96,6 +96,11 @@ bool FileDb::reopenDb(const QString &newFileName) ...@@ -96,6 +96,11 @@ bool FileDb::reopenDb(const QString &newFileName)
return SQLiteDb::reopenDb(newFileName, SQLiteDb::CREATE_MISSING); return SQLiteDb::reopenDb(newFileName, SQLiteDb::CREATE_MISSING);
} }
bool FileDb::moveDb(const QString &newFileName)
{
return SQLiteDb::moveDb(newFileName, SQLiteDb::CREATE_MISSING);
}
bool FileDb::deleteFilesFromDb(qint64 dmId) bool FileDb::deleteFilesFromDb(qint64 dmId)
{ {
QSqlQuery query(m_db); QSqlQuery query(m_db);
......
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
* *
* This program is distributed in the hope that it will be useful, * This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
...@@ -67,6 +67,14 @@ public: ...@@ -67,6 +67,14 @@ public:
*/ */
bool reopenDb(const QString &newFileName); bool reopenDb(const QString &newFileName);
/*!
* @brief Move db.
*
* @param[in] newFileName New file path.
* @return True on success.
*/
bool moveDb(const QString &newFileName);
/*! /*!
* @brief Delete all files related to message with given id. * @brief Delete all files related to message with given id.
* *
......
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
* *
* This program is distributed in the hope that it will be useful, * This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
...@@ -68,6 +68,11 @@ bool MessageDb::reopenDb(const QString &newFileName) ...@@ -68,6 +68,11 @@ bool MessageDb::reopenDb(const QString &newFileName)
return SQLiteDb::reopenDb(newFileName, SQLiteDb::CREATE_MISSING); return SQLiteDb::reopenDb(newFileName, SQLiteDb::CREATE_MISSING);
} }
bool MessageDb::moveDb(const QString &newFileName)