From eba33bea8a81faf337589de7cea3ebfc7eb497ec Mon Sep 17 00:00:00 2001 From: blue Date: Fri, 28 Jun 2019 18:15:30 +0300 Subject: [PATCH] debugging vanished messages --- .gitmodules | 3 +++ CMakeLists.txt | 1 + core/account.cpp | 33 +++++++++++++++++++++++++++++---- core/account.h | 11 +++++++---- core/contact.cpp | 14 ++++++++------ external/qxmpp | 1 + ui/conversation.cpp | 5 +++-- ui/models/contact.cpp | 2 +- 8 files changed, 53 insertions(+), 17 deletions(-) create mode 100644 .gitmodules create mode 160000 external/qxmpp diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 0000000..bbe5364 --- /dev/null +++ b/.gitmodules @@ -0,0 +1,3 @@ +[submodule "external/qxmpp"] + path = external/qxmpp + url = https://github.com/qxmpp-project/qxmpp.git diff --git a/CMakeLists.txt b/CMakeLists.txt index b6f702c..934dfae 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -23,6 +23,7 @@ target_link_libraries(squawk Qt5::Widgets) add_subdirectory(ui) add_subdirectory(core) +add_subdirectory(external/qxmpp) target_link_libraries(squawk squawkUI) target_link_libraries(squawk squawkCORE) diff --git a/core/account.cpp b/core/account.cpp index d4b4eec..7d98834 100644 --- a/core/account.cpp +++ b/core/account.cpp @@ -1,5 +1,5 @@ #include "account.h" -#include +#include #include #include @@ -48,6 +48,7 @@ Account::Account(const QString& p_login, const QString& p_server, const QString& client.addExtension(am); + QObject::connect(am, SIGNAL(logMessage(QXmppLogger::MessageType, const QString&)), this, SLOT(onMamLog(QXmppLogger::MessageType, const QString))); QObject::connect(am, SIGNAL(archivedMessageReceived(const QString&, const QXmppMessage&)), this, SLOT(onMamMessageReceived(const QString&, const QXmppMessage&))); QObject::connect(am, SIGNAL(resultsRecieved(const QString&, const QXmppResultSetReply&, bool)), this, SLOT(onMamResultsReceived(const QString&, const QXmppResultSetReply&, bool))); @@ -395,7 +396,13 @@ void Core::Account::onMessageReceived(const QXmppMessage& msg) break; } if (!handled) { - qDebug() << "Message wasn't handled: "; + logMessage(msg); + } +} + +void Core::Account::logMessage(const QXmppMessage& msg, const QString& reason) +{ + qDebug() << reason; qDebug() << "- from: " << msg.from(); qDebug() << "- to: " << msg.to(); qDebug() << "- body: " << msg.body(); @@ -410,9 +417,9 @@ void Core::Account::onMessageReceived(const QXmppMessage& msg) qDebug() << "- thread: " << msg.thread(); qDebug() << "- isMarkable: " << msg.isMarkable(); qDebug() << "=============================="; - } } + QString Core::Account::getFullJid() const { return getLogin() + "@" + getServer() + "/" + getResource(); @@ -512,6 +519,8 @@ void Core::Account::onMamMessageReceived(const QString& queryId, const QXmppMess QString jid = itr->second; std::map::const_iterator citr = contacts.find(jid); + logMessage(msg, "MAM MESSAGE:"); + if (citr != contacts.end()) { Contact* cnt = citr->second; if (msg.id().size() > 0 && msg.body().size() > 0) { @@ -567,7 +576,7 @@ void Core::Account::onContactNeedHistory(const QString& before, const QString& a query.setAfter(after); } - qDebug() << "Remote query from\"" << after << "\", to" << before; + qDebug() << "Remote query from" << after << ", to" << before; QString q = am->retrieveArchivedMessages("", "", contact->jid, QDateTime(), QDateTime(), query); achiveQueries.insert(std::make_pair(q, contact->jid)); @@ -578,6 +587,16 @@ void Core::Account::onMamResultsReceived(const QString& queryId, const QXmppResu { std::map::const_iterator itr = achiveQueries.find(queryId); QString jid = itr->second; + + + qDebug() << "MAM RESULTS:"; + qDebug() << "complete:" << complete; + qDebug() << "count:" << resultSetReply.count(); + qDebug() << "first:" << resultSetReply.first(); + qDebug() << "last:" << resultSetReply.last(); + qDebug() << "index:" << resultSetReply.index(); + qDebug() << "isNull:" << resultSetReply.isNull(); + achiveQueries.erase(itr); std::map::const_iterator citr = contacts.find(jid); if (citr != contacts.end()) { @@ -588,6 +607,12 @@ void Core::Account::onMamResultsReceived(const QString& queryId, const QXmppResu } } +void Core::Account::onMamLog(QXmppLogger::MessageType type, const QString& msg) +{ + qDebug() << "MAM MESSAGE LOG::"; + qDebug() << msg; +} + void Core::Account::onContactGroupAdded(const QString& group) { Contact* contact = static_cast(sender()); diff --git a/core/account.h b/core/account.h index a9a7e85..145970d 100644 --- a/core/account.h +++ b/core/account.h @@ -5,10 +5,10 @@ #include #include -#include -#include -#include -#include +#include +#include +#include +#include #include "../global.h" #include "contact.h" @@ -107,6 +107,8 @@ private slots: void onContactSubscriptionStateChanged(Shared::SubscriptionState state); void onContactHistoryResponse(const std::list& list); void onContactNeedHistory(const QString& before, const QString& after); + + void onMamLog(QXmppLogger::MessageType type, const QString &msg); private: void addedAccount(const QString &bareJid); @@ -116,6 +118,7 @@ private: void removeFromGroup(const QString& jid, const QString& group); void initializeMessage(Shared::Message& target, const QXmppMessage& source, bool outgoing = false, bool forwarded = false, bool guessing = false) const; Shared::SubscriptionState castSubscriptionState(QXmppRosterIq::Item::SubscriptionType qs) const; + void logMessage(const QXmppMessage& msg, const QString& reason = "Message wasn't handled: "); }; } diff --git a/core/contact.cpp b/core/contact.cpp index e60903c..c6104ef 100644 --- a/core/contact.cpp +++ b/core/contact.cpp @@ -110,7 +110,7 @@ unsigned int Core::Contact::groupsCount() const void Core::Contact::addMessageToArchive(const Shared::Message& msg) { if (msg.getId().size() > 0 && msg.getBody().size() > 0) { - hisoryCache.emplace_back(msg); + hisoryCache.push_back(msg); } } @@ -219,13 +219,13 @@ void Core::Contact::appendMessageToArchive(const Shared::Message& msg) case empty: if (archive->addElement(msg)) { archiveState = end; - }; + } if (!syncronizing) { requestHistory(-1, id); } break; case beginning: - appendCache.emplace_back(msg); + appendCache.push_back(msg); if (!syncronizing) { requestHistory(-1, id); } @@ -234,7 +234,7 @@ void Core::Contact::appendMessageToArchive(const Shared::Message& msg) archive->addElement(msg); break; case chunk: - appendCache.emplace_back(msg); + appendCache.push_back(msg); if (!syncronizing) { requestHistory(-1, id); } @@ -299,8 +299,10 @@ void Core::Contact::flushMessagesToArchive(bool finished, const QString& firstId std::list arc = archive->getBefore(requestedCount - responseCache.size(), before); responseCache.insert(responseCache.begin(), arc.begin(), arc.end()); found = true; - } catch (Archive::NotFound e) {} - if (!found || requestedCount < responseCache.size()) { + } catch (Archive::NotFound e) { + + } + if (!found || requestedCount > responseCache.size()) { if (archiveState == complete) { nextRequest(); } else { diff --git a/external/qxmpp b/external/qxmpp new file mode 160000 index 0000000..e6eb0b7 --- /dev/null +++ b/external/qxmpp @@ -0,0 +1 @@ +Subproject commit e6eb0b78d0cb17fccd5ddb60966ba2a0a2d2b593 diff --git a/ui/conversation.cpp b/ui/conversation.cpp index 5eb5440..1829986 100644 --- a/ui/conversation.cpp +++ b/ui/conversation.cpp @@ -108,8 +108,9 @@ void Conversation::setName(const QString& name) void Conversation::updateState() { - m_ui->statusIcon->setPixmap(contact->getStatusIcon(true).pixmap(40)); - m_ui->statusIcon->setToolTip(Shared::availabilityNames[contact->getAvailability()]); + Shared::Availability av = contact->getAvailability(); + m_ui->statusIcon->setPixmap(Shared::availabilityIcon(av, true).pixmap(40)); + m_ui->statusIcon->setToolTip(Shared::availabilityNames[av]); } void Conversation::setStatus(const QString& status) diff --git a/ui/models/contact.cpp b/ui/models/contact.cpp index 1b211cc..d2d03af 100644 --- a/ui/models/contact.cpp +++ b/ui/models/contact.cpp @@ -223,7 +223,7 @@ QIcon Models::Contact::getStatusIcon(bool big) const } else if (state == Shared::both) { return Shared::availabilityIcon(availability, big);; } else { - return QIcon::fromTheme(Shared::subscriptionStateThemeIcons[state]); + return Shared::subscriptionStateIcon(state); } }