uploading multiple messages fix, some warnings fix

This commit is contained in:
Blue 2019-11-17 13:24:12 +03:00
parent 0c33d81c59
commit fe27955689
14 changed files with 51 additions and 56 deletions

View file

@ -1103,6 +1103,8 @@ void Core::Account::onClientError(QXmppClient::Error err)
case QXmppClient::KeepAliveError:
errorText = "Client keep alive error";
break;
case QXmppClient::NoError:
break; //not exactly sure what to do here
}
qDebug() << errorType << errorText;
@ -1565,11 +1567,7 @@ void Core::Account::uploadVCard(const Shared::VCard& card)
initializeQXmppVCard(iq, card);
bool avatarChanged = false;
if (card.getAvatarType() == Shared::Avatar::empty) {
if (avatarType.size() > 0) {
avatarChanged = true;
}
} else {
if (card.getAvatarType() != Shared::Avatar::empty) {
QString newPath = card.getAvatarPath();
QString oldPath = getAvatarPath();
QByteArray data;
@ -1584,7 +1582,6 @@ void Core::Account::uploadVCard(const Shared::VCard& card)
QFile oA(oldPath);
if (!oA.open(QFile::ReadOnly)) {
qDebug() << "Couldn't read old avatar of account" << name << ", uploading empty avatar";
avatarChanged = true;
} else {
data = oA.readAll();
}
@ -1598,7 +1595,6 @@ void Core::Account::uploadVCard(const Shared::VCard& card)
QFile oA(oldPath);
if (!oA.open(QFile::ReadOnly)) {
qDebug() << "Couldn't read old avatar of account" << name << ", uploading empty avatar";
avatarChanged = true;
} else {
data = oA.readAll();
}

View file

@ -74,18 +74,18 @@ void Core::Archive::open(const QString& account)
mdb_txn_begin(environment, NULL, 0, &txn);
try {
fromTheBeginning = getStatBoolValue("beginning", txn);
} catch (NotFound e) {
} catch (const NotFound& e) {
fromTheBeginning = false;
}
try {
hasAvatar = getStatBoolValue("hasAvatar", txn);
} catch (NotFound e) {
} catch (const NotFound& e) {
hasAvatar = false;
}
if (hasAvatar) {
try {
avatarAutoGenerated = getStatBoolValue("avatarAutoGenerated", txn);
} catch (NotFound e) {
} catch (const NotFound& e) {
avatarAutoGenerated = false;
}
@ -346,8 +346,7 @@ long unsigned int Core::Archive::size() const
throw Closed("size", jid.toStdString());
}
MDB_txn *txn;
int rc;
rc = mdb_txn_begin(environment, NULL, MDB_RDONLY, &txn);
mdb_txn_begin(environment, NULL, MDB_RDONLY, &txn);
MDB_stat stat;
mdb_stat(txn, order, &stat);
mdb_txn_abort(txn);
@ -473,13 +472,12 @@ void Core::Archive::printOrder()
{
qDebug() << "Printing order";
MDB_txn *txn;
int rc;
rc = mdb_txn_begin(environment, NULL, MDB_RDONLY, &txn);
mdb_txn_begin(environment, NULL, MDB_RDONLY, &txn);
MDB_cursor* cursor;
rc = mdb_cursor_open(txn, order, &cursor);
mdb_cursor_open(txn, order, &cursor);
MDB_val lmdbKey, lmdbData;
rc = mdb_cursor_get(cursor, &lmdbKey, &lmdbData, MDB_FIRST);
mdb_cursor_get(cursor, &lmdbKey, &lmdbData, MDB_FIRST);
do {
std::string sId((char*)lmdbData.mv_data, lmdbData.mv_size);
@ -493,13 +491,12 @@ void Core::Archive::printOrder()
void Core::Archive::printKeys()
{
MDB_txn *txn;
int rc;
rc = mdb_txn_begin(environment, NULL, MDB_RDONLY, &txn);
mdb_txn_begin(environment, NULL, MDB_RDONLY, &txn);
MDB_cursor* cursor;
rc = mdb_cursor_open(txn, main, &cursor);
mdb_cursor_open(txn, main, &cursor);
MDB_val lmdbKey, lmdbData;
rc = mdb_cursor_get(cursor, &lmdbKey, &lmdbData, MDB_FIRST);
mdb_cursor_get(cursor, &lmdbKey, &lmdbData, MDB_FIRST);
do {
std::string sId((char*)lmdbKey.mv_data, lmdbKey.mv_size);
@ -540,7 +537,6 @@ bool Core::Archive::getStatBoolValue(const std::string& id, MDB_txn* txn)
std::string Core::Archive::getStatStringValue(const std::string& id, MDB_txn* txn)
{
MDB_cursor* cursor;
MDB_val lmdbKey, lmdbData;
lmdbKey.mv_size = id.size();
lmdbKey.mv_data = (char*)id.c_str();

View file

@ -53,9 +53,9 @@ void Core::NetworkAccess::fileLocalPathRequest(const QString& messageId, const Q
files.removeRecord(url);
emit fileLocalPathResponse(messageId, "");
}
} catch (Archive::NotFound e) {
} catch (const Archive::NotFound& e) {
emit fileLocalPathResponse(messageId, "");
} catch (Archive::Unknown e) {
} catch (const Archive::Unknown& e) {
qDebug() << "Error requesting file path:" << e.what();
emit fileLocalPathResponse(messageId, "");
}
@ -82,9 +82,9 @@ void Core::NetworkAccess::downladFileRequest(const QString& messageId, const QSt
files.removeRecord(url);
startDownload(messageId, url);
}
} catch (Archive::NotFound e) {
} catch (const Archive::NotFound& e) {
startDownload(messageId, url);
} catch (Archive::Unknown e) {
} catch (const Archive::Unknown& e) {
qDebug() << "Error requesting file path:" << e.what();
emit downloadFileError(messageId, QString("Database error: ") + e.what());
}
@ -454,9 +454,9 @@ void Core::NetworkAccess::uploadFileRequest(const QString& messageId, const QStr
startUpload(messageId, url, path);
}
}
} catch (Archive::NotFound e) {
} catch (const Archive::NotFound& e) {
startUpload(messageId, url, path);
} catch (Archive::Unknown e) {
} catch (const Archive::Unknown& e) {
qDebug() << "Error requesting file path on upload:" << e.what();
emit uploadFileError(messageId, QString("Database error: ") + e.what());
}

View file

@ -141,11 +141,11 @@ void Core::RosterItem::performRequest(int count, const QString& before)
std::list<Shared::Message> arc = archive->getBefore(requestedCount - responseCache.size(), lBefore);
responseCache.insert(responseCache.begin(), arc.begin(), arc.end());
found = true;
} catch (Archive::NotFound e) {
} catch (const Archive::NotFound& e) {
requestCache.emplace_back(requestedCount, before);
requestedCount = -1;
emit needHistory(archive->oldestId(), "");
} catch (Archive::Empty e) {
} catch (const Archive::Empty& e) {
requestCache.emplace_back(requestedCount, before);
requestedCount = -1;
emit needHistory(archive->oldestId(), "");
@ -171,9 +171,9 @@ void Core::RosterItem::performRequest(int count, const QString& before)
try {
std::list<Shared::Message> arc = archive->getBefore(requestedCount - responseCache.size(), before);
responseCache.insert(responseCache.begin(), arc.begin(), arc.end());
} catch (Archive::NotFound e) {
} catch (const Archive::NotFound& e) {
qDebug("requesting id hasn't been found in archive, skipping");
} catch (Archive::Empty e) {
} catch (const Archive::Empty& e) {
qDebug("requesting id hasn't been found in archive, skipping");
}
nextRequest();
@ -254,6 +254,7 @@ void Core::RosterItem::flushMessagesToArchive(bool finished, const QString& firs
case empty:
wasEmpty = true;
archiveState = end;
[[fallthrough]];
case end:
added += archive->addElements(appendCache);
appendCache.clear();
@ -274,9 +275,9 @@ void Core::RosterItem::flushMessagesToArchive(bool finished, const QString& firs
std::list<Shared::Message> arc = archive->getBefore(requestedCount - responseCache.size(), before);
responseCache.insert(responseCache.begin(), arc.begin(), arc.end());
found = true;
} catch (Archive::NotFound e) {
} catch (const Archive::NotFound& e) {
} catch (Archive::Empty e) {
} catch (const Archive::Empty& e) {
}
if (!found || requestedCount > responseCache.size()) {

View file

@ -51,7 +51,7 @@ void Core::Squawk::stop()
QSettings settings;
settings.beginGroup("core");
settings.beginWriteArray("accounts");
for (int i = 0; i < accounts.size(); ++i) {
for (std::deque<Account*>::size_type i = 0; i < accounts.size(); ++i) {
settings.setArrayIndex(i);
Account* acc = accounts[i];
settings.setValue("name", acc->getName());