debugging vanished messages

This commit is contained in:
Blue 2019-06-28 18:15:30 +03:00
parent f313c72a97
commit eba33bea8a
8 changed files with 53 additions and 17 deletions

3
.gitmodules vendored Normal file
View File

@ -0,0 +1,3 @@
[submodule "external/qxmpp"]
path = external/qxmpp
url = https://github.com/qxmpp-project/qxmpp.git

View File

@ -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)

View File

@ -1,5 +1,5 @@
#include "account.h"
#include <qxmpp/QXmppMessage.h>
#include <QXmppMessage.h>
#include <QDateTime>
#include <QTimer>
@ -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<QString, Contact*>::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<QString, QString>::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<QString, Contact*>::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<Contact*>(sender());

View File

@ -5,10 +5,10 @@
#include <map>
#include <set>
#include <qxmpp/QXmppRosterManager.h>
#include <qxmpp/QXmppCarbonManager.h>
#include <qxmpp/QXmppMamManager.h>
#include <qxmpp/QXmppClient.h>
#include <QXmppRosterManager.h>
#include <QXmppCarbonManager.h>
#include <QXmppMamManager.h>
#include <QXmppClient.h>
#include "../global.h"
#include "contact.h"
@ -107,6 +107,8 @@ private slots:
void onContactSubscriptionStateChanged(Shared::SubscriptionState state);
void onContactHistoryResponse(const std::list<Shared::Message>& 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: ");
};
}

View File

@ -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<Shared::Message> 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 {

1
external/qxmpp vendored Submodule

@ -0,0 +1 @@
Subproject commit e6eb0b78d0cb17fccd5ddb60966ba2a0a2d2b593

View File

@ -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)

View File

@ -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);
}
}