achive from the beginning memorizing bugfix, limitation of the requests in the model
This commit is contained in:
parent
e0ef1ef797
commit
270a32db9e
17 changed files with 62 additions and 39 deletions
|
@ -434,13 +434,13 @@ void Core::Account::requestArchive(const QString& jid, int count, const QString&
|
|||
|
||||
if (contact == 0) {
|
||||
qDebug() << "An attempt to request archive for" << jid << "in account" << name << ", but the contact with such id wasn't found, skipping";
|
||||
emit responseArchive(jid, std::list<Shared::Message>());
|
||||
emit responseArchive(jid, std::list<Shared::Message>(), true);
|
||||
return;
|
||||
}
|
||||
|
||||
if (state != Shared::ConnectionState::connected) {
|
||||
qDebug() << "An attempt to request archive for" << jid << "in account" << name << ", but the account is not online, skipping";
|
||||
emit responseArchive(contact->jid, std::list<Shared::Message>());
|
||||
emit responseArchive(contact->jid, std::list<Shared::Message>(), false);
|
||||
}
|
||||
|
||||
contact->requestHistory(count, before);
|
||||
|
@ -909,3 +909,13 @@ void Core::Account::handleDisconnection()
|
|||
ownVCardRequestInProgress = false;
|
||||
}
|
||||
|
||||
void Core::Account::onContactHistoryResponse(const std::list<Shared::Message>& list, bool last)
|
||||
{
|
||||
RosterItem* contact = static_cast<RosterItem*>(sender());
|
||||
|
||||
qDebug() << "Collected history for contact " << contact->jid << list.size() << "elements";
|
||||
if (last) {
|
||||
qDebug() << "The response contains the first accounted message";
|
||||
}
|
||||
emit responseArchive(contact->jid, list, last);
|
||||
}
|
||||
|
|
|
@ -127,7 +127,7 @@ signals:
|
|||
void removePresence(const QString& jid, const QString& name);
|
||||
void message(const Shared::Message& data);
|
||||
void changeMessage(const QString& jid, const QString& id, const QMap<QString, QVariant>& data);
|
||||
void responseArchive(const QString& jid, const std::list<Shared::Message>& list);
|
||||
void responseArchive(const QString& jid, const std::list<Shared::Message>& list, bool last);
|
||||
void error(const QString& text);
|
||||
void addRoomParticipant(const QString& jid, const QString& nickName, const QMap<QString, QVariant>& data);
|
||||
void changeRoomParticipant(const QString& jid, const QString& nickName, const QMap<QString, QVariant>& data);
|
||||
|
@ -183,6 +183,7 @@ private slots:
|
|||
|
||||
void onDiscoveryItemsReceived (const QXmppDiscoveryIq& items);
|
||||
void onDiscoveryInfoReceived (const QXmppDiscoveryIq& info);
|
||||
void onContactHistoryResponse(const std::list<Shared::Message>& list, bool last);
|
||||
|
||||
private:
|
||||
void handleDisconnection();
|
||||
|
|
|
@ -502,8 +502,9 @@ long unsigned int Core::Archive::size() const
|
|||
mdb_txn_begin(environment, NULL, MDB_RDONLY, &txn);
|
||||
MDB_stat stat;
|
||||
mdb_stat(txn, order, &stat);
|
||||
size_t amount = stat.ms_entries;
|
||||
mdb_txn_abort(txn);
|
||||
return stat.ms_entries;
|
||||
return amount;
|
||||
}
|
||||
|
||||
std::list<Shared::Message> Core::Archive::getBefore(int count, const QString& id)
|
||||
|
@ -603,10 +604,10 @@ void Core::Archive::setFromTheBeginning(bool is)
|
|||
MDB_txn *txn;
|
||||
mdb_txn_begin(environment, NULL, 0, &txn);
|
||||
bool success = setStatValue("beginning", is, txn);
|
||||
if (success != 0) {
|
||||
mdb_txn_abort(txn);
|
||||
} else {
|
||||
if (success) {
|
||||
mdb_txn_commit(txn);
|
||||
} else {
|
||||
mdb_txn_abort(txn);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -190,7 +190,7 @@ void Core::RosterHandler::removeContactRequest(const QString& jid)
|
|||
void Core::RosterHandler::handleNewRosterItem(Core::RosterItem* contact)
|
||||
{
|
||||
connect(contact, &RosterItem::needHistory, this->acc, &Account::onContactNeedHistory);
|
||||
connect(contact, &RosterItem::historyResponse, this, &RosterHandler::onContactHistoryResponse);
|
||||
connect(contact, &RosterItem::historyResponse, this->acc, &Account::onContactHistoryResponse);
|
||||
connect(contact, &RosterItem::nameChanged, this, &RosterHandler::onContactNameChanged);
|
||||
connect(contact, &RosterItem::avatarChanged, this, &RosterHandler::onContactAvatarChanged);
|
||||
connect(contact, &RosterItem::requestVCard, this->acc, &Account::requestVCard);
|
||||
|
@ -315,14 +315,6 @@ void Core::RosterHandler::removeFromGroup(const QString& jid, const QString& gro
|
|||
}
|
||||
}
|
||||
|
||||
void Core::RosterHandler::onContactHistoryResponse(const std::list<Shared::Message>& list)
|
||||
{
|
||||
RosterItem* contact = static_cast<RosterItem*>(sender());
|
||||
|
||||
qDebug() << "Collected history for contact " << contact->jid << list.size() << "elements";
|
||||
emit acc->responseArchive(contact->jid, list);
|
||||
}
|
||||
|
||||
Core::RosterItem * Core::RosterHandler::getRosterItem(const QString& jid)
|
||||
{
|
||||
RosterItem* item = 0;
|
||||
|
|
|
@ -86,7 +86,6 @@ private slots:
|
|||
void onContactGroupRemoved(const QString& group);
|
||||
void onContactNameChanged(const QString& name);
|
||||
void onContactSubscriptionStateChanged(Shared::SubscriptionState state);
|
||||
void onContactHistoryResponse(const std::list<Shared::Message>& list);
|
||||
void onContactAvatarChanged(Shared::Avatar, const QString& path);
|
||||
|
||||
private:
|
||||
|
|
|
@ -122,7 +122,20 @@ void Core::RosterItem::nextRequest()
|
|||
{
|
||||
if (syncronizing) {
|
||||
if (requestedCount != -1) {
|
||||
emit historyResponse(responseCache);
|
||||
bool last = false;
|
||||
if (archiveState == beginning || archiveState == complete) {
|
||||
QString firstId = archive->oldestId();
|
||||
if (responseCache.size() == 0) {
|
||||
if (requestedBefore == firstId) {
|
||||
last = true;
|
||||
}
|
||||
} else {
|
||||
if (responseCache.front().getId() == firstId) {
|
||||
last = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
emit historyResponse(responseCache, last);
|
||||
}
|
||||
}
|
||||
if (requestCache.size() > 0) {
|
||||
|
@ -529,7 +542,7 @@ void Core::RosterItem::clearArchiveRequests()
|
|||
requestedBefore = "";
|
||||
for (const std::pair<int, QString>& pair : requestCache) {
|
||||
if (pair.first != -1) {
|
||||
emit historyResponse(responseCache); //just to notify those who still waits with whatever happened to be left in caches yet
|
||||
emit historyResponse(responseCache, false); //just to notify those who still waits with whatever happened to be left in caches yet
|
||||
}
|
||||
responseCache.clear();
|
||||
}
|
||||
|
|
|
@ -81,7 +81,7 @@ public:
|
|||
signals:
|
||||
void nameChanged(const QString& name);
|
||||
void subscriptionStateChanged(Shared::SubscriptionState state);
|
||||
void historyResponse(const std::list<Shared::Message>& messages);
|
||||
void historyResponse(const std::list<Shared::Message>& messages, bool last);
|
||||
void needHistory(const QString& before, const QString& after, const QDateTime& afterTime = QDateTime());
|
||||
void avatarChanged(Shared::Avatar, const QString& path);
|
||||
void requestVCard(const QString& jid);
|
||||
|
|
|
@ -357,10 +357,10 @@ void Core::Squawk::requestArchive(const QString& account, const QString& jid, in
|
|||
itr->second->requestArchive(jid, count, before);
|
||||
}
|
||||
|
||||
void Core::Squawk::onAccountResponseArchive(const QString& jid, const std::list<Shared::Message>& list)
|
||||
void Core::Squawk::onAccountResponseArchive(const QString& jid, const std::list<Shared::Message>& list, bool last)
|
||||
{
|
||||
Account* acc = static_cast<Account*>(sender());
|
||||
emit responseArchive(acc->getName(), jid, list);
|
||||
emit responseArchive(acc->getName(), jid, list, last);
|
||||
}
|
||||
|
||||
void Core::Squawk::modifyAccountRequest(const QString& name, const QMap<QString, QVariant>& map)
|
||||
|
|
|
@ -64,7 +64,7 @@ signals:
|
|||
void removePresence(const QString& account, const QString& jid, const QString& name);
|
||||
void stateChanged(Shared::Availability state);
|
||||
void accountMessage(const QString& account, const Shared::Message& data);
|
||||
void responseArchive(const QString& account, const QString& jid, const std::list<Shared::Message>& list);
|
||||
void responseArchive(const QString& account, const QString& jid, const std::list<Shared::Message>& list, bool last);
|
||||
void addRoom(const QString& account, const QString jid, const QMap<QString, QVariant>& data);
|
||||
void changeRoom(const QString& account, const QString jid, const QMap<QString, QVariant>& data);
|
||||
void removeRoom(const QString& account, const QString jid);
|
||||
|
@ -146,7 +146,7 @@ private slots:
|
|||
void onAccountAddPresence(const QString& jid, const QString& name, const QMap<QString, QVariant>& data);
|
||||
void onAccountRemovePresence(const QString& jid, const QString& name);
|
||||
void onAccountMessage(const Shared::Message& data);
|
||||
void onAccountResponseArchive(const QString& jid, const std::list<Shared::Message>& list);
|
||||
void onAccountResponseArchive(const QString& jid, const std::list<Shared::Message>& list, bool last);
|
||||
void onAccountAddRoom(const QString jid, const QMap<QString, QVariant>& data);
|
||||
void onAccountChangeRoom(const QString jid, const QMap<QString, QVariant>& data);
|
||||
void onAccountRemoveRoom(const QString jid);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue