uploading multiple messages fix, some warnings fix
This commit is contained in:
parent
09a946c204
commit
0cb25a25cf
@ -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();
|
||||
}
|
||||
|
@ -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();
|
||||
|
@ -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());
|
||||
}
|
||||
|
@ -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()) {
|
||||
|
@ -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());
|
||||
|
@ -322,7 +322,7 @@ void Models::Contact::getMessages(Models::Contact::Messages& container) const
|
||||
void Models::Contact::toOfflineState()
|
||||
{
|
||||
emit childIsAboutToBeRemoved(this, 0, childItems.size());
|
||||
for (int i = 0; i < childItems.size(); ++i) {
|
||||
for (std::deque<Item*>::size_type i = 0; i < childItems.size(); ++i) {
|
||||
Item* item = childItems[i];
|
||||
disconnect(item, &Item::childChanged, this, &Contact::refresh);
|
||||
Item::_removeChild(i);
|
||||
|
@ -236,7 +236,7 @@ void Models::Room::getMessages(Models::Room::Messages& container) const
|
||||
void Models::Room::toOfflineState()
|
||||
{
|
||||
emit childIsAboutToBeRemoved(this, 0, childItems.size());
|
||||
for (int i = 0; i < childItems.size(); ++i) {
|
||||
for (std::deque<Item*>::size_type i = 0; i < childItems.size(); ++i) {
|
||||
Item* item = childItems[i];
|
||||
Item::_removeChild(i);
|
||||
item->deleteLater();
|
||||
|
@ -518,7 +518,7 @@ void Models::Roster::removeGroup(const QString& account, const QString& name)
|
||||
|
||||
if (toInsert.size() > 0) {
|
||||
Account* acc = accounts.find("account")->second;
|
||||
for (int i = 0; i < toInsert.size(); ++i) {
|
||||
for (std::deque<Contact*>::size_type i = 0; i < toInsert.size(); ++i) {
|
||||
Contact* cont = toInsert[i];
|
||||
acc->appendChild(cont); //TODO optimisation
|
||||
}
|
||||
|
@ -111,7 +111,7 @@ MessageLine::Position MessageLine::message(const Shared::Message& msg, bool forc
|
||||
}
|
||||
}
|
||||
messageIndex.insert(std::make_pair(id, message));
|
||||
int index = std::distance<Order::const_iterator>(messageOrder.begin(), result.first); //need to make with binary indexed tree
|
||||
unsigned long index = std::distance<Order::const_iterator>(messageOrder.begin(), result.first); //need to make with binary indexed tree
|
||||
Position res = invalid;
|
||||
if (index == 0) {
|
||||
res = beggining;
|
||||
|
@ -24,6 +24,7 @@
|
||||
#include <QGraphicsDropShadowEffect>
|
||||
#include <QFileDialog>
|
||||
#include <QMimeDatabase>
|
||||
#include <unistd.h>
|
||||
|
||||
Conversation::Conversation(bool muc, const QString& mJid, const QString mRes, const QString pJid, const QString pRes, const QString& acc, QWidget* parent):
|
||||
QWidget(parent),
|
||||
@ -205,6 +206,7 @@ void Conversation::onEnterPressed()
|
||||
msg.generateRandomId();
|
||||
msg.setCurrentTime();
|
||||
line->appendMessageWithUpload(msg, badge->id);
|
||||
usleep(1000); //this is required for the messages not to have equal time when appending into messageline
|
||||
}
|
||||
clearAttachedFiles();
|
||||
}
|
||||
|
@ -145,7 +145,7 @@ QModelIndex UI::VCard::EMailsModel::addNewEmptyLine()
|
||||
return createIndex(deque.size() - 1, 0, &(deque.back()));
|
||||
}
|
||||
|
||||
bool UI::VCard::EMailsModel::isPreferred(int row) const
|
||||
bool UI::VCard::EMailsModel::isPreferred(quint32 row) const
|
||||
{
|
||||
if (row < deque.size()) {
|
||||
return deque[row].prefered;
|
||||
@ -154,10 +154,10 @@ bool UI::VCard::EMailsModel::isPreferred(int row) const
|
||||
}
|
||||
}
|
||||
|
||||
void UI::VCard::EMailsModel::removeLines(int index, int count)
|
||||
void UI::VCard::EMailsModel::removeLines(quint32 index, quint32 count)
|
||||
{
|
||||
if (index < deque.size()) {
|
||||
int maxCount = deque.size() - index;
|
||||
quint32 maxCount = deque.size() - index;
|
||||
if (count > maxCount) {
|
||||
count = maxCount;
|
||||
}
|
||||
@ -194,12 +194,12 @@ void UI::VCard::EMailsModel::setEmails(const std::deque<Shared::VCard::Email>& e
|
||||
}
|
||||
}
|
||||
|
||||
void UI::VCard::EMailsModel::revertPreferred(int row)
|
||||
void UI::VCard::EMailsModel::revertPreferred(quint32 row)
|
||||
{
|
||||
setData(createIndex(row, 2), !isPreferred(row));
|
||||
}
|
||||
|
||||
QString UI::VCard::EMailsModel::getEmail(int row) const
|
||||
QString UI::VCard::EMailsModel::getEmail(quint32 row) const
|
||||
{
|
||||
return deque[row].address;
|
||||
}
|
||||
|
@ -40,16 +40,16 @@ public:
|
||||
QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const override;
|
||||
bool setData(const QModelIndex &index, const QVariant &value, int role = Qt::EditRole) override;
|
||||
Qt::ItemFlags flags(const QModelIndex &index) const override;
|
||||
bool isPreferred(int row) const;
|
||||
bool isPreferred(quint32 row) const;
|
||||
|
||||
void removeLines(int index, int count);
|
||||
void removeLines(quint32 index, quint32 count);
|
||||
void setEmails(const std::deque<Shared::VCard::Email>& emails);
|
||||
void getEmails(std::deque<Shared::VCard::Email>& emails) const;
|
||||
QString getEmail(int row) const;
|
||||
QString getEmail(quint32 row) const;
|
||||
|
||||
public slots:
|
||||
QModelIndex addNewEmptyLine();
|
||||
void revertPreferred(int row);
|
||||
void revertPreferred(quint32 row);
|
||||
|
||||
private:
|
||||
bool edit;
|
||||
|
@ -129,7 +129,7 @@ void UI::VCard::PhonesModel::getPhones(std::deque<Shared::VCard::Phone>& phones)
|
||||
}
|
||||
}
|
||||
|
||||
bool UI::VCard::PhonesModel::isPreferred(int row) const
|
||||
bool UI::VCard::PhonesModel::isPreferred(quint32 row) const
|
||||
{
|
||||
if (row < deque.size()) {
|
||||
return deque[row].prefered;
|
||||
@ -138,10 +138,10 @@ bool UI::VCard::PhonesModel::isPreferred(int row) const
|
||||
}
|
||||
}
|
||||
|
||||
void UI::VCard::PhonesModel::removeLines(int index, int count)
|
||||
void UI::VCard::PhonesModel::removeLines(quint32 index, quint32 count)
|
||||
{
|
||||
if (index < deque.size()) {
|
||||
int maxCount = deque.size() - index;
|
||||
quint32 maxCount = deque.size() - index;
|
||||
if (count > maxCount) {
|
||||
count = maxCount;
|
||||
}
|
||||
@ -156,7 +156,7 @@ void UI::VCard::PhonesModel::removeLines(int index, int count)
|
||||
}
|
||||
}
|
||||
|
||||
void UI::VCard::PhonesModel::revertPreferred(int row)
|
||||
void UI::VCard::PhonesModel::revertPreferred(quint32 row)
|
||||
{
|
||||
setData(createIndex(row, 3), !isPreferred(row));
|
||||
}
|
||||
@ -216,7 +216,7 @@ void UI::VCard::PhonesModel::setPhones(const std::deque<Shared::VCard::Phone>& p
|
||||
}
|
||||
}
|
||||
|
||||
QString UI::VCard::PhonesModel::getPhone(int row) const
|
||||
QString UI::VCard::PhonesModel::getPhone(quint32 row) const
|
||||
{
|
||||
return deque[row].number;
|
||||
}
|
||||
|
@ -41,16 +41,16 @@ public:
|
||||
int rowCount(const QModelIndex& parent) const override;
|
||||
bool setData(const QModelIndex &index, const QVariant &value, int role = Qt::EditRole) override;
|
||||
Qt::ItemFlags flags(const QModelIndex &index) const override;
|
||||
bool isPreferred(int row) const;
|
||||
bool isPreferred(quint32 row) const;
|
||||
|
||||
void removeLines(int index, int count);
|
||||
void removeLines(quint32 index, quint32 count);
|
||||
void setPhones(const std::deque<Shared::VCard::Phone>& phones);
|
||||
void getPhones(std::deque<Shared::VCard::Phone>& phones) const;
|
||||
QString getPhone(int row) const;
|
||||
QString getPhone(quint32 row) const;
|
||||
|
||||
public slots:
|
||||
QModelIndex addNewEmptyLine();
|
||||
void revertPreferred(int row);
|
||||
void revertPreferred(quint32 row);
|
||||
|
||||
private:
|
||||
bool edit;
|
||||
|
Loading…
Reference in New Issue
Block a user