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

Consequently using macros based on LogDevice for event logging.

parent 9eab1252
......@@ -67,7 +67,7 @@ void Accounts::updateAccountCounters(const QVariant &acntModelVariant)
AccountListModel::fromVariant(acntModelVariant);
if (accountModel == Q_NULLPTR) {
/* accountModel can be NULL when app is shutdown */
qWarning("%s", "Cannot access account model.");
logWarningNL("%s", "Cannot access account model.");
return;
}
......@@ -90,7 +90,7 @@ void Accounts::updateNewMessageCounter(const QVariant &acntModelVariant,
AccountListModel::fromVariant(acntModelVariant);
if (accountModel == Q_NULLPTR) {
/* accountModel can be NULL when app is shutdown */
qWarning("%s", "Cannot access account model.");
logWarningNL("%s", "Cannot access account model.");
return;
}
......@@ -98,7 +98,7 @@ void Accounts::updateNewMessageCounter(const QVariant &acntModelVariant,
GlobInstcs::setPtr->dbsLocation, userName,
(*GlobInstcs::acntMapPtr)[userName].storeToDisk());
if (msgDb == Q_NULLPTR) {
qCritical("%s", "Cannot open message database.");
logErrorNL("%s", "Cannot access message database.");
return;
}
......@@ -150,7 +150,7 @@ bool Accounts::createAccount(const QVariant &acntModelVariant,
AccountListModel::fromVariant(acntModelVariant);
if (accountModel == Q_NULLPTR) {
Q_ASSERT(0);
qCritical("%s", "Cannot access account model.");
logErrorNL("%s", "Cannot access account model.");
return false;
}
......@@ -202,7 +202,7 @@ bool Accounts::updateAccount(const QVariant &acntModelVariant,
AccountListModel::fromVariant(acntModelVariant);
if (accountModel == Q_NULLPTR) {
Q_ASSERT(0);
qCritical("%s", "Cannot access account model.");
logErrorNL("%s", "Cannot access account model.");
return false;
}
......@@ -293,7 +293,7 @@ bool Accounts::removeAccount(const QVariant &acntModelVariant,
AccountListModel::fromVariant(acntModelVariant);
if (accountModel == Q_NULLPTR) {
Q_ASSERT(0);
qCritical("%s", "Cannot access account model.");
logErrorNL("%s", "Cannot access account model.");
return false;
}
......@@ -317,11 +317,11 @@ bool Accounts::removeAccount(const QVariant &acntModelVariant,
GlobInstcs::setPtr->dbsLocation, userName,
(*GlobInstcs::acntMapPtr)[userName].storeToDisk());
if (fDb == Q_NULLPTR) {
qCritical("%s", "Cannot open file database.");
logErrorNL("%s", "Cannot access file database.");
return false;
}
if (!GlobInstcs::fileDbsPtr->deleteDb(fDb)) {
qCritical("%s", "Could not delete file database.");
logErrorNL("%s", "Could not delete file database.");
return false;
}
......@@ -330,23 +330,23 @@ bool Accounts::removeAccount(const QVariant &acntModelVariant,
GlobInstcs::setPtr->dbsLocation, userName,
(*GlobInstcs::acntMapPtr)[userName].storeToDisk());
if (msgDb == Q_NULLPTR) {
qCritical("%s", "Cannot open message database.");
logErrorNL("%s", "Cannot access message database.");
return false;
}
if (!GlobInstcs::messageDbsPtr->deleteDb(msgDb)) {
qCritical("%s", "Could not delete message database.");
logErrorNL("%s", "Could not delete message database.");
return false;
}
/* Delete account info from account database */
if (!GlobInstcs::accountDbPtr->deleteAccountInfoFromDb(userName)) {
qCritical("%s", "Could not delete account info.");
logErrorNL("%s", "Could not delete account info.");
return false;
}
/* Delete user info from account database */
if (!GlobInstcs::accountDbPtr->deleteUserInfoFromDb(userName)) {
qCritical("%s", "Could not delete user info.");
logErrorNL("%s", "Could not delete user info.");
return false;
}
......@@ -372,7 +372,7 @@ void Accounts::loadModelCounters(AccountListModel *accountModel)
if (accountModel == Q_NULLPTR) {
Q_ASSERT(0);
qCritical("%s", "Cannot access account model.");
logErrorNL("%s", "Cannot access account model.");
return;
}
......@@ -388,7 +388,7 @@ void Accounts::loadModelCounters(AccountListModel *accountModel)
GlobInstcs::setPtr->dbsLocation, userName,
(*GlobInstcs::acntMapPtr)[userName].storeToDisk());
if (msgDb == Q_NULLPTR) {
qWarning("Cannot open message database for '%s'.",
logWarningNL("Cannot open message database for '%s'.",
userName.toUtf8().constData());
continue;
}
......
......@@ -23,6 +23,7 @@
#include <QString>
#include "src/datovka_shared/log/log.h"
#include "src/datovka_shared/records_management/conversion.h"
QList<qint64> createIdList(const QStringList &strList, bool *ok)
......@@ -36,7 +37,7 @@ QList<qint64> createIdList(const QStringList &strList, bool *ok)
if (ok != Q_NULLPTR) {
*ok = false;
}
qCritical("Cannot convert '%s' into qint64.",
logErrorNL("Cannot convert '%s' into qint64.",
str.toUtf8().constData());
return QList<qint64>();
}
......@@ -44,7 +45,7 @@ QList<qint64> createIdList(const QStringList &strList, bool *ok)
if (ok != Q_NULLPTR) {
*ok = false;
}
qCritical("%s", "Received negative identifier.");
logErrorNL("%s", "Received negative identifier.");
return QList<qint64>();
}
}
......
......@@ -148,7 +148,8 @@ bool RecordsManagementConnection::communicate(enum ServiceId srvcId,
} else {
/* Timeout expired. */
disconnect(reply, SIGNAL(finished()), &eventLoop, SLOT(quit()));
qCritical("Connection timed out. Check your internet connection.");
logErrorNL("%s",
"Connection timed out. Check your internet connection.");
reply->abort();
}
......@@ -196,7 +197,7 @@ bool RecordsManagementConnection::addTrustedCertificate(const QString &filePath)
filePath.toUtf8().constData());
return true;
} else {
qWarning("Supplied certificate '%s' is not in PEM format.",
logWarningNL("Supplied certificate '%s' is not in PEM format.",
filePath.toUtf8().constData());
}
if (readAndAddCert(certData, QSsl::Der)) {
......@@ -204,11 +205,11 @@ bool RecordsManagementConnection::addTrustedCertificate(const QString &filePath)
filePath.toUtf8().constData());
return true;
} else {
qWarning("Supplied certificate '%s' is not in DER format.",
logWarningNL("Supplied certificate '%s' is not in DER format.",
filePath.toUtf8().constData());
}
qCritical("Could not read certificate '%s'.",
logErrorNL("Could not read certificate '%s'.",
filePath.toUtf8().constData());
return false;
}
......@@ -228,11 +229,11 @@ void RecordsManagementConnection::handleSslErrors(QNetworkReply *reply,
errMsg = errList.join(QStringLiteral("; "));
}
qCritical("%s", errMsg.toUtf8().constData());
logErrorNL("%s", errMsg.toUtf8().constData());
emit connectionError(errMsg);
if (m_ignoreSslErrors) {
qWarning("Ignoring obtained SSL errors.");
logWarningNL("%s", "Ignoring obtained SSL errors.");
emit connectionError(QStringLiteral("Ignoring obtained SSL errors."));
if (reply != Q_NULLPTR) {
......@@ -268,7 +269,7 @@ QNetworkReply *RecordsManagementConnection::sendRequest(
switch (m_nam.networkAccessible()) {
case QNetworkAccessManager::UnknownAccessibility:
case QNetworkAccessManager::NotAccessible:
qCritical("%s",
logErrorNL("%s",
"Internet connection is probably not available. Check your network settings.");
return Q_NULLPTR;
break;
......@@ -285,7 +286,7 @@ QNetworkReply *RecordsManagementConnection::sendRequest(
}
if (reply == Q_NULLPTR) {
qCritical("%s", "No reply.");
logErrorNL("%s", "No reply.");
return Q_NULLPTR;
}
......@@ -323,12 +324,12 @@ bool RecordsManagementConnection::processReply(QNetworkReply *reply,
case 302: /* 302 Found */
possibleRedirectUrl = reply->attribute(
QNetworkRequest::RedirectionTargetAttribute);
qWarning("Redirection '%s'?",
logWarningNL("Redirection '%s'?",
possibleRedirectUrl.toString().toUtf8().constData());
// possibleRedirectUrl.toString();
break;
default: /* Any other error. */
qCritical("%s", reply->errorString().toUtf8().constData());
logErrorNL("%s", reply->errorString().toUtf8().constData());
return false;
break;
}
......
......@@ -26,6 +26,7 @@
#include <QJsonParseError>
#include <QJsonValue>
#include "src/datovka_shared/log/log.h"
#include "src/datovka_shared/records_management/json/helper.h"
bool JsonHelper::readRootObject(const QByteArray &json, QJsonObject &jsonObj)
......@@ -35,19 +36,19 @@ bool JsonHelper::readRootObject(const QByteArray &json, QJsonObject &jsonObj)
QJsonParseError parseErr;
jsonDoc = QJsonDocument::fromJson(json, &parseErr);
if (jsonDoc.isNull()) {
qCritical("Error parsing JSON: %s",
logErrorNL("Error parsing JSON: %s",
parseErr.errorString().toUtf8().constData());
return false;
}
}
if (!jsonDoc.isObject()) {
qCritical("%s", "JSON document contains no object.");
logErrorNL("%s", "JSON document contains no object.");
return false;
}
QJsonObject jsonTmpObj(jsonDoc.object());
if (jsonTmpObj.isEmpty()) {
qCritical("%s", "JSON object is empty.");
logErrorNL("%s", "JSON object is empty.");
return false;
}
......@@ -59,13 +60,13 @@ bool JsonHelper::readValue(const QJsonObject &jsonObj, const QString &key,
QJsonValue &jsonVal)
{
if (jsonObj.isEmpty() || key.isEmpty()) {
qCritical("%s", "JSON object or sought key is empty.");
logErrorNL("%s", "JSON object or sought key is empty.");
return false;
}
jsonVal = jsonObj.value(key);
if (jsonVal.isUndefined()) {
qCritical("Missing key '%s' in JSON object.",
logErrorNL("Missing key '%s' in JSON object.",
key.toUtf8().constData());
return false;
}
......@@ -86,7 +87,7 @@ bool JsonHelper::readInt(const QJsonObject &jsonObj, const QString &key,
}
int readVal = jsonVal.toInt(-1);
if (readVal == -1) {
qCritical("Value related to key '%s' is not an integer.",
logErrorNL("Value related to key '%s' is not an integer.",
key.toUtf8().constData());
return false;
}
......@@ -107,7 +108,7 @@ bool JsonHelper::readString(const QJsonObject &jsonObj, const QString &key,
return acceptNull;
}
if (!jsonVal.isString()) {
qCritical("Value related to key '%s' is not a string.",
logErrorNL("Value related to key '%s' is not a string.",
key.toUtf8().constData());
return false;
}
......@@ -128,7 +129,7 @@ bool JsonHelper::readArray(const QJsonObject &jsonObj, const QString &key,
return acceptNull;
}
if (!jsonVal.isArray()) {
qCritical("Value related to key '%s' is not an array.",
logErrorNL("Value related to key '%s' is not an array.",
key.toUtf8().constData());
return false;
}
......@@ -149,11 +150,11 @@ bool JsonHelper::readStringList(const QJsonObject &jsonObj, const QString &key,
foreach (const QJsonValue &jsonVal, jsonArr) {
if (jsonVal.isNull()) {
qCritical("%s", "Found null value in array.");
logErrorNL("%s", "Found null value in array.");
return false;
}
if (!jsonVal.isString()) {
qCritical("%s", "Found non-string value in array.");
logErrorNL("%s", "Found non-string value in array.");
return false;
}
......@@ -175,7 +176,7 @@ QString JsonHelper::toIndentedString(const QByteArray &json)
QJsonParseError parseErr;
jsonDoc = QJsonDocument::fromJson(json, &parseErr);
if (jsonDoc.isNull()) {
qCritical("Error parsing JSON: %s",
logErrorNL("Error parsing JSON: %s",
parseErr.errorString().toUtf8().constData());
return QString();
}
......
......@@ -26,6 +26,7 @@
#include <QJsonObject>
#include <QJsonValue>
#include "src/datovka_shared/log/log.h"
#include "src/datovka_shared/records_management/json/helper.h"
#include "src/datovka_shared/records_management/json/upload_hierarchy.h"
......@@ -164,7 +165,7 @@ UploadHierarchyResp::NodeEntry *UploadHierarchyResp::NodeEntry::fromJsonRecursiv
foreach (const QJsonValue &jsonVal, jsonArr) {
if (!jsonVal.isObject()) {
qCritical("%s",
logErrorNL("%s",
"Sub-node array holds a non-object value.");
ok = false;
deleteRecursive(newEntry);
......
/*
* Copyright (C) 2014-2017 CZ.NIC
* Copyright (C) 2014-2018 CZ.NIC
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
......@@ -22,12 +22,12 @@
*/
#include <QClipboard>
#include <QDebug>
#include <QDialogButtonBox>
#include <QGuiApplication>
#include <QPlainTextEdit>
#include <QPushButton>
#include "src/datovka_shared/log/log.h"
#include "src/dialogues/widget_input_dialogue.h"
WidgetInputDialogue::WidgetInputDialogue(QWidget *parent, Qt::WindowFlags flags)
......@@ -108,7 +108,7 @@ void WidgetInputDialogue::extendDialoguePaste(void)
m_textField = findEditArea();
if (m_textField == Q_NULLPTR) {
/* No suitable text field found. */
qWarning("Could not find editable area.\n");
logWarningNL("%s", "Could not find editable area.");
return;
}
......@@ -118,7 +118,7 @@ void WidgetInputDialogue::extendDialoguePaste(void)
}
if (buttonBox == Q_NULLPTR) {
qWarning("Could not locate button box.\n");
logWarningNL("%s", "Could not locate button box.");
m_textField = Q_NULLPTR;
return;
}
......@@ -127,7 +127,7 @@ void WidgetInputDialogue::extendDialoguePaste(void)
tr("Paste"), QDialogButtonBox::ActionRole);
if (m_pasteButton == Q_NULLPTR) {
qWarning("Could not create paste button.\n");
logWarningNL("%s", "Could not create paste button.");
m_textField = Q_NULLPTR;
return;
}
......@@ -140,7 +140,7 @@ void WidgetInputDialogue::extendDialoguePaste(void)
m_timer.setInterval(500);
m_timer.start();
qInfo("Created and connected paste button.\n");
logInfoNL("%s", "Created and connected paste button.");
}
QObject *WidgetInputDialogue::findEditArea(void) const
......
......@@ -27,6 +27,7 @@
#include <QStandardPaths>
#include <QTextStream>
#include "src/datovka_shared/log/log.h"
#include "src/io/filesystem.h"
/*!
......@@ -180,7 +181,7 @@ QString existingAppPath(const QString &basePath, const QString &dirName)
QDir dir(newPath);
if (!dir.exists() && !dir.mkpath(".")) {
qCritical("Location '%s' could not be created.",
logErrorNL("Location '%s' could not be created.",
newPath.toUtf8().constData());
return QString();
}
......@@ -199,7 +200,8 @@ QString writeFile(const QString &filePath, const QString &fileName,
QFile fout(nonconflictingFileName(filePath + QDir::separator()
+ nameCopy));
if (!fout.open(QIODevice::WriteOnly)) {
qCritical("Cannot open file '%s'.", nameCopy.toUtf8().constData());
logErrorNL("Cannot open file '%s'.",
nameCopy.toUtf8().constData());
return QString();
}
......
......@@ -316,7 +316,7 @@ int main(int argc, char *argv[])
GlobInstcs::msgProcEmitterPtr =
new (std::nothrow) MessageProcessingEmitter;
if (GlobInstcs::msgProcEmitterPtr == Q_NULLPTR) {
qCritical("Cannot create status message emitter.");
logErrorNL("%s", "Cannot create status message emitter.");
return EXIT_FAILURE;
}
/*
......@@ -328,20 +328,21 @@ int main(int argc, char *argv[])
*/
GlobInstcs::workPoolPtr = new (std::nothrow) WorkerPool(1);
if (GlobInstcs::workPoolPtr == Q_NULLPTR) {
qCritical("Cannot create worker pool.");
logErrorNL("%s", "Cannot create worker pool.");
return EXIT_FAILURE;
}
GlobInstcs::setPtr = new (std::nothrow) Settings;
if (GlobInstcs::setPtr == Q_NULLPTR) {
qCritical("Cannot create settings.");
logErrorNL("%s", "Cannot create settings.");
return EXIT_FAILURE;
}
GlobInstcs::recMgmtSetPtr =
new (std::nothrow) RecordsManagementSettings;
if (GlobInstcs::recMgmtSetPtr == Q_NULLPTR) {
qCritical("Cannot create records management settings.");
logErrorNL("%s",
"Cannot create records management settings.");
return EXIT_FAILURE;
}
}
......@@ -481,13 +482,13 @@ int main(int argc, char *argv[])
GlobInstcs::acntMapPtr = new (std::nothrow) AccountsMap;
if (GlobInstcs::acntMapPtr == Q_NULLPTR) {
qCritical("Cannot allocate account map.");
logErrorNL("%s", "Cannot allocate account map.");
return EXIT_FAILURE;
}
GlobInstcs::imgProvPtr = new (std::nothrow) ImageProvider;
if (GlobInstcs::imgProvPtr == Q_NULLPTR) {
qCritical("Cannot create image provider.");
logErrorNL("%s", "Cannot create image provider.");
return EXIT_FAILURE;
}
}
......@@ -495,7 +496,7 @@ int main(int argc, char *argv[])
/* Create and initialise account model. */
AccountListModel *accountModelPtr = new (std::nothrow) AccountListModel;
if (Q_NULLPTR == accountModelPtr) {
qCritical("Cannot create account model.");
logErrorNL("%s", "Cannot create account model.");
return EXIT_FAILURE;
}
accountModelPtr->setObjectName("mainAccountModel");
......@@ -596,15 +597,15 @@ int main(int argc, char *argv[])
}
}
if (found) {
qInfo() << "Found following CA certificate:" << pem_desc->name;
logInfoNL("Found following CA certificate: %s", pem_desc->name);
} else {
qWarning() << "Missing following CA certificate:" << pem_desc->name;
logWarningNL("Missing following CA certificate: %s", pem_desc->name);
QSslCertificate cert(QByteArray(pem_desc->pem), QSsl::Pem);
if (!cert.isNull()) {
QSslSocket::addDefaultCaCertificate(cert);
qInfo() << "Added following CA certificate:" << pem_desc->name;
logInfoNL("Added following CA certificate: %s", pem_desc->name);
} else {
qCritical() << "Cannot read CA certificate:" << pem_desc->name;;
logErrorNL("Cannot read CA certificate: %s", pem_desc->name);
}
}
++pem_desc;
......
......@@ -90,7 +90,7 @@ void Messages::fillContactList(const QVariant &dbModelVariant,
DataboxListModel::fromVariant(dbModelVariant);
if (databoxModel == Q_NULLPTR) {
Q_ASSERT(0);
qCritical("%s", "Cannot access databox model.");
logErrorNL("%s", "Cannot access databox model.");
return;
}
......@@ -98,7 +98,7 @@ void Messages::fillContactList(const QVariant &dbModelVariant,
GlobInstcs::setPtr->dbsLocation, userName,
(*GlobInstcs::acntMapPtr)[userName].storeToDisk());
if (msgDb == Q_NULLPTR) {
qCritical("%s", "Cannot open message database.");
logErrorNL("%s", "Cannot access message database.");
return;
}
......@@ -122,7 +122,7 @@ void Messages::fillMessageList(const QVariant &msgModelVariant,
MessageListModel::fromVariant(msgModelVariant);
if (messageModel == Q_NULLPTR) {
Q_ASSERT(0);
qCritical("%s", "Cannot access message model.");
logErrorNL("%s", "Cannot access message model.");
return;
}
......@@ -130,7 +130,7 @@ void Messages::fillMessageList(const QVariant &msgModelVariant,
GlobInstcs::setPtr->dbsLocation, userName,
(*GlobInstcs::acntMapPtr)[userName].storeToDisk());
if (msgDb == Q_NULLPTR) {
qCritical("%s", "Cannot open message database.");
logErrorNL("%s", "Cannot access message database.");
return;
}
......@@ -162,7 +162,7 @@ QString Messages::getMessageDetail(const QString &userName,
GlobInstcs::setPtr->dbsLocation, userName,
(*GlobInstcs::acntMapPtr)[userName].storeToDisk());
if (msgDb == Q_NULLPTR) {
qCritical("%s", "Cannot open message database.");
logErrorNL("%s", "Cannot access message database.");
return QString();
}
return msgDb->getMessageDetailHtmlFromDb(msgId);
......@@ -184,7 +184,7 @@ QmlIsdsEnvelope *Messages::getMsgEnvelopeDataAndSetRecipient(
GlobInstcs::setPtr->dbsLocation, userName,
(*GlobInstcs::acntMapPtr)[userName].storeToDisk());
if (msgDb == Q_NULLPTR) {
qCritical("%s", "Cannot open message database.");
logErrorNL("%s", "Cannot access message database.");
return Q_NULLPTR;
}
......@@ -221,7 +221,7 @@ void Messages::markMessageAsLocallyRead(const QVariant &msgModelVariant,
GlobInstcs::setPtr->dbsLocation, userName,
(*GlobInstcs::acntMapPtr)[userName].storeToDisk());
if (msgDb == Q_NULLPTR) {
qCritical("%s", "Cannot open message database.");
logErrorNL("%s", "Cannot access message database.");
return;
}
msgDb->markMessageLocallyRead(msgId, isRead);
......@@ -229,7 +229,7 @@ void Messages::markMessageAsLocallyRead(const QVariant &msgModelVariant,
MessageListModel *messageModel =
MessageListModel::fromVariant(msgModelVariant);
if (messageModel == Q_NULLPTR) {
qWarning("%s", "Cannot access message model.");
logWarningNL("%s", "Cannot access message model.");
return;
}
messageModel->overrideRead(msgId, isRead);
......@@ -251,7 +251,7 @@ void Messages::markMessagesAsLocallyRead(const QVariant &msgModelVariant,
GlobInstcs::setPtr->dbsLocation, userName,
(*GlobInstcs::acntMapPtr)[userName].storeToDisk());
if (msgDb == Q_NULLPTR) {
qCritical("%s", "Cannot open message database.");
logErrorNL("%s", "Cannot access message database.");
return;
}
msgDb->markMessagesLocallyRead(enumToDbRepr(msgType), isRead);
......@@ -259,7 +259,7 @@ void Messages::markMessagesAsLocallyRead(const QVariant &msgModelVariant,
MessageListModel *messageModel =
MessageListModel::fromVariant(msgModelVariant);
if (messageModel == Q_NULLPTR) {
qWarning("%s", "Cannot access message model.");
logWarningNL("%s", "Cannot access message model.");
return;
}
/* The current model should correspond with supplied type. */
......@@ -274,7 +274,7 @@ void Messages::updateRmStatus(const QVariant &msgModelVariant,
MessageListModel *messageModel =
MessageListModel::fromVariant(msgModelVariant);
if (messageModel == Q_NULLPTR) {
qWarning("%s", "Cannot access message model.");
logWarningNL("%s", "Cannot access message model.");
return;
}
messageModel->updateRmStatus(dmId, isUploadRm);
......@@ -315,7 +315,7 @@ void Messages::deleteMessageFromDbs(const QVariant &acntModelVariant,
GlobInstcs::setPtr->dbsLocation, userName,
(*GlobInstcs::acntMapPtr)[userName].storeToDisk());
if (msgDb == Q_NULLPTR) {
qCritical("%s", "Cannot open message database.");
logErrorNL("%s", "Cannot access message database.");
return;
}
......@@ -323,7 +323,7 @@ void Messages::deleteMessageFromDbs(const QVariant &acntModelVariant,
GlobInstcs::setPtr->dbsLocation, userName,
(*GlobInstcs::acntMapPtr)[userName].storeToDisk());
if (fDb == Q_NULLPTR) {
qCritical("Cannot open file database for %s.",
logErrorNL("Cannot access file database for %s.",
userName.toUtf8().constData());
return;
}
......@@ -331,13 +331,13 @@ void Messages::deleteMessageFromDbs(const QVariant &acntModelVariant,
AccountListModel *accountModel =
AccountListModel::fromVariant(acntModelVariant);
if (accountModel == Q_NULLPTR) {
qWarning("%s", "Cannot access account model.");
logWarningNL("%s", "Cannot access account model.");
}
MessageListModel *messageModel =
MessageListModel::fromVariant(msgModelVariant);
if (messageModel == Q_NULLPTR) {
qWarning("%s", "Cannot access message model.");
logWarningNL("%s", "Cannot access message model.");
}
if (fDb->deleteFilesFromDb(msgId)) {
......@@ -423,7 +423,7 @@ void Messages::deleteExpiredMessagesFromDbs(int days)
GlobInstcs::setPtr->dbsLocation, userName,
(*GlobInstcs::acntMapPtr)[userName].storeToDisk());
if (msgDb == Q_NULLPTR) {
qCritical("Cannot open message database for %s.",
logErrorNL("Cannot access message database for %s.",
userName.toUtf8().constData());
return;
}
......@@ -437,7 +437,7 @@ void Messages::deleteExpiredMessagesFromDbs(int days)
GlobInstcs::setPtr->dbsLocation, userName,
(*GlobInstcs::acntMapPtr)[userName].storeToDisk());
if (fDb == Q_NULLPTR) {
qCritical("Cannot open file database for %s.",
logErrorNL("Cannot access file database for %s.",
userName.toUtf8().constData());
return;
}
......@@ -495,7 +495,8 @@ int Messages::getAllDbSize(void)
GlobInstcs::setPtr->dbsLocation, userName,
(*GlobInstcs::acntMapPtr)[userName].storeToDisk());
if (msgDb == Q_NULLPTR) {
qCritical("Cannot open message database for user name '%s'.",
logErrorNL(
"Cannot access message database for user name '%s'.",
userName.toUtf8().constData());
return -1;
}
......@@ -505,7 +506,8 @@ int Messages::getAllDbSize(void)
GlobInstcs::setPtr->dbsLocation, userName,
(*GlobInstcs::acntMapPtr)[userName].storeToDisk());
if (fDb == Q_NULLPTR) {
qCritical("Cannot open file database for user name '%s'.",
logErrorNL(
"Cannot access file database for user name '%s'.",
userName.toUtf8().constData());
return -1;
}
......@@ -561,7 +563,8 @@ bool Messages::relocateDatabases(const QString &newLocationDir,
(*GlobInstcs::acntMapPtr)[userName].storeToDisk());
relocationSucceeded = (mDb != Q_NULLPTR);
if (!relocationSucceeded) {
qWarning("Cannot access message database for user name '%s'.",
logWarningNL(
"Cannot access message database for user name '%s'.",
userName.toUtf8().constData());
break; /* Break the for cycle. */
}
......@@ -570,7 +573,8 @@ bool Messages::relocateDatabases(const QString &newLocationDir,
(*GlobInstcs::acntMapPtr)[userName].storeToDisk());
relocationSucceeded = (fDb != Q_NULLPTR);
if (!relocationSucceeded) {
qWarning("Cannot access file database for user name '%s'.",
logWarningNL(
"Cannot access file database for user name '%s'.",
userName.toUtf8().constData());
break; /* Break the for cycle. */
}
......@@ -653,7 +657,7 @@ bool Messages::relocateDatabases(const QString &newLocationDir,
if (entry.first->openDb(entry.second, true)) {
QFile::remove(newLocation);
} else {
qCritical(
logErrorNL(
"Cannot revert to original message database file '%s'.",
entry.second.toUtf8().constData());
/* TODO -- Critical. Cannot revert. */
......@@ -664,7 +668,7 @@ bool Messages::relocateDatabases(const QString &newLocationDir,
if (entry.first->openDb(entry.second, true)) {
QFile::remove(newLocation);
} else {
qCritical(
logErrorNL(
"Cannot revert to original file database file '%s'.",
entry.second.toUtf8().constData());
/* TODO -- Critical. Cannot revert. */
......@@ -693,7 +697,7 @@ int Messages::searchMsg(const QVariant &msgModelVariant, const QString &phrase,
MessageListModel::fromVariant(msgModelVariant);
if (messageModel == Q_NULLPTR) {
Q_ASSERT(0);
qCritical("%s", "Cannot access message model.");
logErrorNL("%s", "Cannot access message model.");
return 0;
}
......@@ -709,7 +713,7 @@ int Messages::searchMsg(const QVariant &msgModelVariant, const QString &phrase,
GlobInstcs::setPtr->dbsLocation, userName,
(*GlobInstcs::acntMapPtr)[userName].storeToDisk());
if (fDb == Q_NULLPTR) {
qWarning("%s", "Cannot open file database.");
logWarningNL("%s", "Cannot access file database.");
} else {
msgIds = fDb->searchAttachmentName(phrase);
}
......@@ -722,7 +726,7 @@ int Messages::searchMsg(const QVariant &msgModelVariant, const QString &phrase,
GlobInstcs::setPtr->dbsLocation, userName,
(*GlobInstcs::acntMapPtr)[userName].storeToDisk());
if (msgDb == Q_NULLPTR) {
qCritical("%s", "Cannot open message database.");
logErrorNL("%s", "Cannot access message database.");
continue;
}
......
......@@ -186,7 +186,7 @@ QString AcntData::password(void) const
QString decrypted(decryptPwd(m_pwdCode,
GlobInstcs::setPtr->_pinVal, m_pwdAlg, m_pwdSalt, m_pwdIv));
if (decrypted.isEmpty()) {
qWarning(
logWarningNL(
"Failed decrypting password for user name '%s'.",
m_userName.toUtf8().constData());
}
......@@ -321,7 +321,7 @@ void AcntData::recomputePwd(const QString &oldPin, const QString &newPin)
QString decrypted(decryptPwd(m_pwdCode,
GlobInstcs::setPtr->_pinVal, m_pwdAlg, m_pwdSalt, m_pwdIv));
if (decrypted.isEmpty()) {
qWarning(
logWarningNL(
"Failed decrypting password for user name '%s'.",
m_userName.toUtf8().constData());
}
......@@ -742,7 +742,7 @@ int AccountListModel::addAccount(const AcntData &acntData, QModelIndex *idx)
}
if (m_accountsPtr->contains(userName)) {
qWarning("Account with user name '%s' already exists.",
logWarningNL("Account with username '%s' already exists.",
userName.toUtf8().constData());
return -2;