Verified Commit ac79a787 authored by Phobos D'thorga's avatar Phobos D'thorga 🐲
Browse files

* Cleaned up some code.

* Significantly improved the handling of message archiving and recall from the XMPP server in question and towards the client (i.e. Small World Deluxe).
* Improved commenting of code in some areas, particularly with regard to XMPP-related code.
* Fixed some minor bugs.
parent f859197a
Pipeline #993 passed with stages
in 38 minutes and 44 seconds
......@@ -699,6 +699,7 @@ set(GALAXY_UI_CPP
src/models/tableview/gk_callsign_msgs_model.cpp
src/models/tableview/gk_xmpp_recv_msgs_model.cpp
src/models/tableview/gk_xmpp_roster_presence_model.cpp
src/models/tableview/gk_qdatetime_filter_proxy_model.cpp
src/models/tableview/gk_xmpp_roster_pending_model.cpp
src/models/tableview/gk_xmpp_roster_blocked_model.cpp
src/models/treeview/xmpp/gk_xmpp_roster_model.cpp)
......@@ -800,6 +801,7 @@ set(GALAXY_OBJ_HEADERS
src/models/tableview/gk_callsign_msgs_model.hpp
src/models/tableview/gk_xmpp_recv_msgs_model.hpp
src/models/tableview/gk_xmpp_roster_presence_model.hpp
src/models/tableview/gk_qdatetime_filter_proxy_model.hpp
src/models/tableview/gk_xmpp_roster_pending_model.hpp
src/models/tableview/gk_xmpp_roster_blocked_model.hpp
src/models/treeview/xmpp/gk_xmpp_roster_model.hpp)
......
......@@ -246,69 +246,6 @@ std::string StringFuncs::csvOutputString(const std::deque<std::string> &csv_elem
return std::string();
}
/**
* @brief StringFuncs::calcMinTimestampForXmppMsgHistory calculates the most minimum timestamp applicable to a QList of
* XMPP messages for use in message history archive retrieval functions and so on.
* @author Phobos A. D'thorga <phobos.gekko@gekkofyre.io>
* @param messages The given list of XMPP messages to calculate the most minimum QDateTime timestamp from.
* @return The most mimimum QDateTime timestamp applicable to the given list of XMPP messages.
*/
QDateTime StringFuncs::calcMinTimestampForXmppMsgHistory(const QList<QXmppMessage> &messages)
{
try {
if (!messages.isEmpty()) {
QDateTime min_timestamp = QDateTime::currentDateTimeUtc();
for (const auto &message: messages) {
if (message.isXmppStanza() && !message.body().isEmpty()) {
min_timestamp = messages.at(0).stamp();
if (messages.size() > 1) {
if (min_timestamp < message.stamp()) {
min_timestamp = message.stamp();
}
} else {
break;
}
}
}
return min_timestamp;
}
} catch (const std::exception &e) {
std::throw_with_nested(std::runtime_error(tr("An error has occurred whilst calculating timestamp information from XMPP message history data.\n\n%1").arg(QString::fromStdString(e.what())).toStdString()));
}
return QDateTime::currentDateTimeUtc();
}
/**
* @brief StringFuncs::calcMaxTimestampForXmppMsgHistory calculates the most maximum timestamp applicable to a QList of
* XMPP messages for use in message history archive retrieval functions and so on.
* @author Phobos A. D'thorga <phobos.gekko@gekkofyre.io>
* @param messages The given list of XMPP messages to calculate the most maxmimum QDateTime timestamp from.
* @return The most maximum QDateTime timestamp applicable to the given list of XMPP messages.
*/
QDateTime StringFuncs::calcMaxTimestampForXmppMsgHistory(const QList<QXmppMessage> &messages)
{
try {
if (!messages.isEmpty()) {
QDateTime max_timestamp = messages.at(0).stamp();
if (messages.size() > 1) {
for (const auto &message: messages) {
if (max_timestamp > message.stamp()) {
max_timestamp = message.stamp();
}
}
}
return max_timestamp;
}
} catch (const std::exception &e) {
std::throw_with_nested(std::runtime_error(tr("An error has occurred whilst calculating timestamp information from XMPP message history data.\n\n%1").arg(QString::fromStdString(e.what())).toStdString()));
}
return QDateTime::currentDateTimeUtc();
}
/**
* @brief StringFuncs::htmlSpecialCharEncoding
* @author wysota <https://www.qtcentre.org/threads/52456-HTML-Unicode-ampersand-encoding?p=234858#post234858>,
......
......@@ -92,9 +92,6 @@ public:
std::deque<std::string> csvRemoveElement(const std::deque<std::string> &csv_elements, const std::string &val_to_remove);
std::string csvOutputString(const std::deque<std::string> &csv_elements);
[[nodiscard]] QDateTime calcMinTimestampForXmppMsgHistory(const QList<QXmppMessage> &messages);
[[nodiscard]] QDateTime calcMaxTimestampForXmppMsgHistory(const QList<QXmppMessage> &messages);
static QString htmlSpecialCharEncoding(const QString &string);
QList<int> extractNumbersFromStr(const QString &str);
......
......@@ -305,7 +305,7 @@ GkXmppClient::GkXmppClient(const GkUserConn &connection_details, QPointer<GekkoF
QObject::connect(m_xmppCarbonMgr.get(), SIGNAL(messageSent(const QXmppMessage &)), this, SLOT(recvXmppMsgUpdate(const QXmppMessage &)));
QObject::connect(m_xmppCarbonMgr.get(), SIGNAL(messageReceived(const QXmppMessage &)), this, SLOT(recvXmppMsgUpdate(const QXmppMessage &)));
}
QObject::connect(m_registerManager.get(), SIGNAL(registrationFormReceived(const QXmppRegisterIq &)),
this, SLOT(handleRegistrationForm(const QXmppRegisterIq &)));
......@@ -666,6 +666,81 @@ bool GkXmppClient::isJidOnline(const QString &bareJid)
return false;
}
/**
* @brief GkXmppClient::calcMinTimestampForXmppMsgHistory calculates the most minimum timestamp applicable to a QList of
* XMPP messages for use in message history archive retrieval functions and so on.
* @author Phobos A. D'thorga <phobos.gekko@gekkofyre.io>
* @param bareJid The user we are in communiqué with!
* @param msg_history The given list of XMPP messages to calculate the most minimum QDateTime timestamp from.
* @return The most mimimum QDateTime timestamp applicable to the given list of XMPP messages.
*/
QDateTime GkXmppClient::calcMinTimestampForXmppMsgHistory(const QString &bareJid, const QList<GkXmppCallsign> &msg_history)
{
try {
if (!msg_history.isEmpty()) {
QDateTime min_timestamp = QDateTime::currentDateTimeUtc();
for (const auto &stanza: msg_history) {
if (stanza.bareJid == bareJid) {
for (const auto &mam: stanza.messages) {
if (mam.message.isXmppStanza() && !mam.message.body().isEmpty()) {
min_timestamp = stanza.messages.at(0).message.stamp();
if (msg_history.size() > 1) {
if (min_timestamp < mam.message.stamp()) {
min_timestamp = mam.message.stamp();
}
} else {
break;
}
}
}
break;
}
}
return min_timestamp;
}
} catch (const std::exception &e) {
std::throw_with_nested(std::runtime_error(tr("An error has occurred whilst calculating timestamp information from XMPP message history data.\n\n%1").arg(QString::fromStdString(e.what())).toStdString()));
}
return QDateTime::currentDateTimeUtc();
}
/**
* @brief GkXmppClient::calcMaxTimestampForXmppMsgHistory calculates the most maximum timestamp applicable to a QList of
* XMPP messages for use in message history archive retrieval functions and so on.
* @author Phobos A. D'thorga <phobos.gekko@gekkofyre.io>
* @param bareJid The user we are in communiqué with!
* @param msg_history The given list of XMPP messages to calculate the most maxmimum QDateTime timestamp from.
* @return The most maximum QDateTime timestamp applicable to the given list of XMPP messages.
*/
QDateTime GkXmppClient::calcMaxTimestampForXmppMsgHistory(const QString &bareJid, const QList<GekkoFyre::Network::GkXmpp::GkXmppCallsign> &msg_history)
{
try {
if (!msg_history.isEmpty()) {
if (msg_history.size() > 1) {
for (const auto &stanza: msg_history) {
if (stanza.bareJid == bareJid) {
QDateTime max_timestamp = stanza.messages.at(0).message.stamp();
for (const auto &mam: stanza.messages) {
if (max_timestamp > mam.message.stamp()) {
max_timestamp = mam.message.stamp();
}
}
return max_timestamp;
}
}
}
}
} catch (const std::exception &e) {
std::throw_with_nested(std::runtime_error(tr("An error has occurred whilst calculating timestamp information from XMPP message history data.\n\n%1").arg(QString::fromStdString(e.what())).toStdString()));
}
return QDateTime::currentDateTimeUtc();
}
/**
* @brief GkXmppClient::getRegistrationMgr
* @author Phobos A. D'thorga <phobos.gekko@gekkofyre.io>
......@@ -681,13 +756,13 @@ std::shared_ptr<QXmppRegistrationManager> GkXmppClient::getRegistrationMgr()
* @author Phobos A. D'thorga <phobos.gekko@gekkofyre.io>
* @return
*/
QVector<GekkoFyre::Network::GkXmpp::GkXmppCallsign> GkXmppClient::getRosterMap()
QList<GekkoFyre::Network::GkXmpp::GkXmppCallsign> GkXmppClient::getRosterMap()
{
if (!m_rosterList.isEmpty()) {
return m_rosterList;
}
return QVector<GekkoFyre::Network::GkXmpp::GkXmppCallsign>();
return QList<GekkoFyre::Network::GkXmpp::GkXmppCallsign>();
}
/**
......@@ -695,12 +770,11 @@ QVector<GekkoFyre::Network::GkXmpp::GkXmppCallsign> GkXmppClient::getRosterMap()
* @author Phobos A. D'thorga <phobos.gekko@gekkofyre.io>
* @param rosterList
*/
void GkXmppClient::updateRosterMap(const QVector<GekkoFyre::Network::GkXmpp::GkXmppCallsign> &rosterList)
void GkXmppClient::updateRosterMap(const QList<GekkoFyre::Network::GkXmpp::GkXmppCallsign> &rosterList)
{
if (!rosterList.isEmpty()) {
std::lock_guard<std::mutex> lock_guard(m_updateRosterMapMtx);
m_rosterList.clear();
m_rosterList.shrink_to_fit();
std::copy(rosterList.begin(), rosterList.end(), std::back_inserter(m_rosterList));
}
......@@ -894,19 +968,12 @@ void GkXmppClient::getArchivedMessages(const QString &to, const QString &node, c
if (!start.isValid()) {
if (to == roster.bareJid && jid != m_connDetails.jid) {
if (!roster.messages.isEmpty()) {
QList<QXmppMessage> msg_history;
for (const auto &message: roster.messages) {
msg_history.push_back(message.message);
}
const auto min_timestamp = calcMinTimestampForXmppMsgHistory(to, m_rosterList);
gkEventLogger->publishEvent(tr("Minimum date required for message archive retrieval is: %1").arg(QDateTime(min_timestamp).toString("dd MMM yyyy @ hh:mm:ss.zzz")),
GkSeverity::Debug, "", false, true, false, false);
m_xmppMamMgr->retrieveArchivedMessages(roster.bareJid, "", m_connDetails.jid, min_timestamp, QDateTime(), resultSetQuery);
if (!msg_history.isEmpty()) {
const auto min_timestamp = gkStringFuncs->calcMinTimestampForXmppMsgHistory(msg_history);
gkEventLogger->publishEvent(tr("Minimum date required for message archive retrieval is: %1").arg(QDateTime(min_timestamp).toString("dd MMM yyyy @ hh:mm:ss.zzz")),
GkSeverity::Debug, "", false, true, false, false);
m_xmppMamMgr->retrieveArchivedMessages(roster.bareJid, "", m_connDetails.jid, min_timestamp, QDateTime(), resultSetQuery);
return;
}
return;
}
break;
......
......@@ -128,11 +128,16 @@ public:
[[nodiscard]] bool isJidExist(const QString &bareJid);
[[nodiscard]] bool isJidOnline(const QString &bareJid);
//
// Date & Time Management
[[nodiscard]] QDateTime calcMinTimestampForXmppMsgHistory(const QString &bareJid, const QList<GekkoFyre::Network::GkXmpp::GkXmppCallsign> &msg_history);
[[nodiscard]] QDateTime calcMaxTimestampForXmppMsgHistory(const QString &bareJid, const QList<GekkoFyre::Network::GkXmpp::GkXmppCallsign> &msg_history);
//
// User, roster and presence details
std::shared_ptr<QXmppRegistrationManager> getRegistrationMgr();
QVector<GekkoFyre::Network::GkXmpp::GkXmppCallsign> getRosterMap();
void updateRosterMap(const QVector<GekkoFyre::Network::GkXmpp::GkXmppCallsign> &rosterList);
QList<GekkoFyre::Network::GkXmpp::GkXmppCallsign> getRosterMap();
void updateRosterMap(const QList<GekkoFyre::Network::GkXmpp::GkXmppCallsign> &rosterList);
QXmppPresence statusToPresence(const Network::GkXmpp::GkOnlineStatus &status);
Network::GkXmpp::GkOnlineStatus presenceToStatus(const QXmppPresence::AvailableStatusType &xmppPresence);
QString presenceToString(const QXmppPresence::AvailableStatusType &xmppPresence);
......@@ -294,7 +299,7 @@ private:
std::shared_ptr<QXmppRosterManager> m_rosterManager;
QStringList rosterGroups;
QVector<QString> m_blockList;
QVector<GekkoFyre::Network::GkXmpp::GkXmppCallsign> m_rosterList; // A list of all the bareJids, including the client themselves!
QList<GekkoFyre::Network::GkXmpp::GkXmppCallsign> m_rosterList; // A list of all the bareJids, including the client themselves!
//
// Filesystem & Directories
......
/**
** __ _ _ __ __ _ _
** / _\_ __ ___ __ _| | | / / /\ \ \___ _ __| | __| |
** \ \| '_ ` _ \ / _` | | | \ \/ \/ / _ \| '__| |/ _` |
** _\ \ | | | | | (_| | | | \ /\ / (_) | | | | (_| |
** \__/_| |_| |_|\__,_|_|_| \/ \/ \___/|_| |_|\__,_|
**
** ___ _
** / \___| |_ ___ _____
** / /\ / _ \ | | | \ \/ / _ \
** / /_// __/ | |_| |> < __/
** /___,' \___|_|\__,_/_/\_\___|
**
**
** If you have downloaded the source code for "Small World Deluxe" and are reading this,
** then thank you from the bottom of our hearts for making use of our hard work, sweat
** and tears in whatever you are implementing this into!
**
** Copyright (C) 2020 - 2021. GekkoFyre.
**
** Small World Deluxe is free software: you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by
** the Free Software Foundation, either version 3 of the License, or
** (at your option) any later version.
**
** Small world is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
** GNU General Public License for more details.
**
** You should have received a copy of the GNU General Public License
** along with Small World Deluxe. If not, see <http://www.gnu.org/licenses/>.
**
**
** The latest source code updates can be obtained from [ 1 ] below at your
** discretion. A web-browser or the 'git' application may be required.
**
** [ 1 ] - https://code.gekkofyre.io/amateur-radio/small-world-deluxe
**
****************************************************************************************************/
#include "src/models/tableview/gk_qdatetime_filter_proxy_model.hpp"
using namespace GekkoFyre;
using namespace GkAudioFramework;
using namespace Database;
using namespace Settings;
using namespace Audio;
using namespace AmateurRadio;
using namespace Control;
using namespace Spectrograph;
using namespace System;
using namespace Events;
using namespace Logging;
using namespace Network;
using namespace GkXmpp;
using namespace Security;
/**
* @brief GkQDateTimeFilterProxyModel::GkQDateTimeFilterProxyModel
* @author Phobos A. D'thorga <phobos.gekko@gekkofyre.io>
* @param parent
*/
GkQDateTimeFilterProxyModel::GkQDateTimeFilterProxyModel(QObject *parent) : QSortFilterProxyModel(parent)
{
setParent(parent);
return;
}
/**
* @brief GkQDateTimeFilterProxyModel::~GkQDateTimeFilterProxyModel
* @author Phobos A. D'thorga <phobos.gekko@gekkofyre.io>
*/
GkQDateTimeFilterProxyModel::~GkQDateTimeFilterProxyModel()
{
return;
}
/**
* @brief GkQDateTimeFilterProxyModel::setFilterMinimumDateTime
* @author Phobos A. D'thorga <phobos.gekko@gekkofyre.io>
* @param timestamp
*/
void GkQDateTimeFilterProxyModel::setFilterMinimumDateTime(QDateTime timestamp)
{
if (timestamp.isValid()) {
minTimestamp = timestamp;
invalidateFilter();
}
return;
}
/**
* @brief GkQDateTimeFilterProxyModel::setFilterMaximumDateTime
* @author Phobos A. D'thorga <phobos.gekko@gekkofyre.io>
* @param timestamp
*/
void GkQDateTimeFilterProxyModel::setFilterMaximumDateTime(QDateTime timestamp)
{
if (timestamp.isValid()) {
maxTimestamp = timestamp;
invalidateFilter();
}
return;
}
/**
* @brief GkQDateTimeFilterProxyModel::filterAcceptsRow
* @author Phobos A. D'thorga <phobos.gekko@gekkofyre.io>
* @param sourceRow
* @param sourceParent
* @return
*/
bool GkQDateTimeFilterProxyModel::filterAcceptsRow(int sourceRow, const QModelIndex &sourceParent) const
{
return QSortFilterProxyModel::filterAcceptsRow(sourceRow, sourceParent);
}
/**
* @brief GkQDateTimeFilterProxyModel::lessThan
* @author Phobos A. D'thorga <phobos.gekko@gekkofyre.io>
* @param left
* @param right
* @return
*/
bool GkQDateTimeFilterProxyModel::lessThan(const QModelIndex &left, const QModelIndex &right) const
{
const QVariant leftData = sourceModel()->data(left);
const QVariant rightData = sourceModel()->data(right);
if (leftData.userType() == QMetaType::QDateTime) {
return leftData.toDateTime() < rightData.toDateTime();
}
const QDateTime leftTimestamp = leftData.toDateTime();
const QDateTime rightTimestamp = rightData.toDateTime();
return QString::localeAwareCompare(QString::number(leftTimestamp.toMSecsSinceEpoch()), QString::number(rightTimestamp.toMSecsSinceEpoch())) < 0;
}
/**
* @brief GkQDateTimeFilterProxyModel::dateInRange
* @author Phobos A. D'thorga <phobos.gekko@gekkofyre.io>
* @param timestamp
* @return
*/
bool GkQDateTimeFilterProxyModel::dateInRange(QDateTime timestamp) const
{
return (!minTimestamp.isValid() || timestamp > minTimestamp) && (!maxTimestamp.isValid() || timestamp < maxTimestamp);
}
/**
** __ _ _ __ __ _ _
** / _\_ __ ___ __ _| | | / / /\ \ \___ _ __| | __| |
** \ \| '_ ` _ \ / _` | | | \ \/ \/ / _ \| '__| |/ _` |
** _\ \ | | | | | (_| | | | \ /\ / (_) | | | | (_| |
** \__/_| |_| |_|\__,_|_|_| \/ \/ \___/|_| |_|\__,_|
**
** ___ _
** / \___| |_ ___ _____
** / /\ / _ \ | | | \ \/ / _ \
** / /_// __/ | |_| |> < __/
** /___,' \___|_|\__,_/_/\_\___|
**
**
** If you have downloaded the source code for "Small World Deluxe" and are reading this,
** then thank you from the bottom of our hearts for making use of our hard work, sweat
** and tears in whatever you are implementing this into!
**
** Copyright (C) 2020 - 2021. GekkoFyre.
**
** Small World Deluxe is free software: you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by
** the Free Software Foundation, either version 3 of the License, or
** (at your option) any later version.
**
** Small world is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
** GNU General Public License for more details.
**
** You should have received a copy of the GNU General Public License
** along with Small World Deluxe. If not, see <http://www.gnu.org/licenses/>.
**
**
** The latest source code updates can be obtained from [ 1 ] below at your
** discretion. A web-browser or the 'git' application may be required.
**
** [ 1 ] - https://code.gekkofyre.io/amateur-radio/small-world-deluxe
**
****************************************************************************************************/
#pragma once
#include "src/defines.hpp"
#include "src/gk_xmpp_client.hpp"
#include <QObject>
#include <QString>
#include <QVariant>
#include <QDateTime>
#include <QTableView>
#include <QModelIndex>
#include <QAbstractTableModel>
#include <QSortFilterProxyModel>
namespace GekkoFyre {
class GkQDateTimeFilterProxyModel : public QSortFilterProxyModel {
Q_OBJECT
public:
explicit GkQDateTimeFilterProxyModel(QObject *parent = nullptr);
~GkQDateTimeFilterProxyModel() override;
[[nodiscard]] QDateTime filterMinimumDateTime() const { return minTimestamp; }
void setFilterMinimumDateTime(QDateTime timestamp);
[[nodiscard]] QDateTime filterMaximumDateTime() const { return maxTimestamp; }
void setFilterMaximumDateTime(QDateTime timestamp);
protected:
bool filterAcceptsRow(int sourceRow, const QModelIndex &sourceParent) const override;
[[nodiscard]] bool lessThan(const QModelIndex &left, const QModelIndex &right) const override;
private:
QDateTime minTimestamp;
QDateTime maxTimestamp;
[[nodiscard]] bool dateInRange(QDateTime timestamp) const;
};
};
......@@ -70,11 +70,7 @@ GkXmppRecvMsgsTableViewModel::GkXmppRecvMsgsTableViewModel(QPointer<QTableView>
QWidget *parent) : QAbstractTableModel(parent)
{
setParent(parent);
proxyModel = new QSortFilterProxyModel(parent);
tableView->setModel(proxyModel);
m_xmppClient = std::move(xmppClient);
proxyModel->setSourceModel(this);
return;
}
......@@ -124,6 +120,7 @@ void GkXmppRecvMsgsTableViewModel::insertData(const QString &bareJid, const QStr
auto top = this->createIndex((m_data.count() + 1), 0, nullptr);
auto bottom = this->createIndex((m_data.count() + 1), GK_XMPP_RECV_MSGS_TABLEVIEW_MODEL_TOTAL_IDX, nullptr);
emit dataChanged(top, bottom);
} catch (const std::exception &e) {
std::throw_with_nested(std::runtime_error(e.what()));
......
......@@ -54,7 +54,6 @@
#include <QTableView>
#include <QModelIndex>
#include <QAbstractTableModel>
#include <QSortFilterProxyModel>
namespace GekkoFyre {
......@@ -82,7 +81,8 @@ public slots:
private:
QList<GekkoFyre::Network::GkXmpp::GkRecvMsgsTableViewModel> m_data;
QPointer<QSortFilterProxyModel> proxyModel;
//
// Miscellaneous
QPointer<QTableView> table;
QPointer<GekkoFyre::GkXmppClient> m_xmppClient;
......
......@@ -118,7 +118,8 @@ GkXmppMessageDialog::GkXmppMessageDialog(QPointer<GekkoFyre::StringFuncs> string
QObject::connect(m_xmppClient, SIGNAL(xmppMsgUpdate(const QXmppMessage &)), this, SLOT(recvXmppMsg(const QXmppMessage &)));
QObject::connect(m_xmppClient, SIGNAL(updateMsgHistory()), this, SLOT(updateMsgHistory()));
QObject::connect(m_xmppClient, SIGNAL(msgArchiveSuccReceived()), this, SLOT(msgArchiveSuccReceived()));
QObject::connect(this, SIGNAL(updateMamArchive(const QString &)), this, SLOT(procMamArchive(const QString &)));
QObject::connect(this, SIGNAL(updateMamArchive(const QString &, const bool &, const bool &)),
this, SLOT(procMamArchive(const QString &, const bool &, const bool &)));
//
// Setup and initialize QTableView's...
......@@ -129,6 +130,7 @@ GkXmppMessageDialog::GkXmppMessageDialog(QPointer<GekkoFyre::StringFuncs> string
ui->tableView_recv_msg_dlg->horizontalHeader()->setSectionResizeMode(GK_XMPP_RECV_MSGS_TABLEVIEW_MODEL_NICKNAME_IDX, QHeaderView::ResizeToContents);
ui->tableView_recv_msg_dlg->horizontalHeader()->setStretchLastSection(true);
ui->tableView_recv_msg_dlg->horizontalHeader()->setHidden(true);
ui->tableView_recv_msg_dlg->setSortingEnabled(false);
ui->tableView_recv_msg_dlg->setVisible(true);
ui->tableView_recv_msg_dlg->show();
ui->tableView_recv_msg_dlg->scrollToBottom();
......@@ -482,11 +484,11 @@ QXmppMessage GkXmppMessageDialog::createXmppMessageIq(const QString &to, const Q
void GkXmppMessageDialog::msgArchiveSuccReceived()
{
if (!startupSucc) {
emit updateMamArchive(gkConnDetails.jid, true, true);
for (const auto &bareJid: m_bareJids) {
emit updateMamArchive(bareJid);
emit updateMamArchive(bareJid, false, true);
}
emit updateMamArchive(gkConnDetails.jid);
startupSucc = true;
}
......@@ -494,15 +496,20 @@ void GkXmppMessageDialog::msgArchiveSuccReceived()
}
/**
* @brief GkXmppMessageDialog::procMamArchive
* @brief GkXmppMessageDialog::procMamArchive is a helper class for dealing with the processing of recorded messages that
* have been archived to a given XMPP server, according to specification, XEP-0313 (Message Archive Management).
* @author Phobos A. D'thorga <phobos.gekko@gekkofyre.io>
* @param bareJid
* @param bareJid The user we are in communiqué with!
* @param wipeExistingHistory Whether to wipe the pre-existing chat history or not, specifically from the given QTableView
* object, GekkoFyre::GkXmppRecvMsgsTableViewModel().
* @param presented Should we update the fact that these messages are now already 'presented' (and thereby inserted into
* the QTableView) or not?
*/
void GkXmppMessageDialog::procMamArchive(const QString &bareJid)
void GkXmppMessageDialog::procMamArchive(const QString &bareJid, const bool &wipeExistingHistory, const bool &presented)
{