mirror of
https://github.com/overte-org/overte.git
synced 2025-08-06 16:36:54 +02:00
Added XMPP archive manager
This commit is contained in:
parent
d24b55871f
commit
029e20edda
3 changed files with 39 additions and 1 deletions
|
@ -21,7 +21,7 @@ const QString DEFAULT_CHAT_ROOM = "public@public-chat.highfidelity.io";
|
||||||
XmppClient::XmppClient() :
|
XmppClient::XmppClient() :
|
||||||
_xmppClient(),
|
_xmppClient(),
|
||||||
_xmppMUCManager()
|
_xmppMUCManager()
|
||||||
{
|
{
|
||||||
AccountManager& accountManager = AccountManager::getInstance();
|
AccountManager& accountManager = AccountManager::getInstance();
|
||||||
connect(&accountManager, SIGNAL(accessTokenChanged()), this, SLOT(connectToServer()));
|
connect(&accountManager, SIGNAL(accessTokenChanged()), this, SLOT(connectToServer()));
|
||||||
connect(&accountManager, SIGNAL(logoutComplete()), this, SLOT(disconnectFromServer()));
|
connect(&accountManager, SIGNAL(logoutComplete()), this, SLOT(disconnectFromServer()));
|
||||||
|
|
|
@ -29,6 +29,8 @@
|
||||||
#include <QMessageBox>
|
#include <QMessageBox>
|
||||||
|
|
||||||
const int NUM_MESSAGES_TO_TIME_STAMP = 20;
|
const int NUM_MESSAGES_TO_TIME_STAMP = 20;
|
||||||
|
const int MAX_HISTORY_CHAT_MESSAGES = 100;
|
||||||
|
const int MAX_HISTORY_DAYS = 7;
|
||||||
|
|
||||||
const QRegularExpression regexLinks("((?:(?:ftp)|(?:https?))://\\S+)");
|
const QRegularExpression regexLinks("((?:(?:ftp)|(?:https?))://\\S+)");
|
||||||
const QRegularExpression regexHifiLinks("([#@]\\S+)");
|
const QRegularExpression regexHifiLinks("([#@]\\S+)");
|
||||||
|
@ -227,10 +229,38 @@ void ChatWindow::connected() {
|
||||||
#ifdef HAVE_QXMPP
|
#ifdef HAVE_QXMPP
|
||||||
const QXmppMucRoom* publicChatRoom = XmppClient::getInstance().getPublicChatRoom();
|
const QXmppMucRoom* publicChatRoom = XmppClient::getInstance().getPublicChatRoom();
|
||||||
connect(publicChatRoom, SIGNAL(participantsChanged()), this, SLOT(participantsChanged()));
|
connect(publicChatRoom, SIGNAL(participantsChanged()), this, SLOT(participantsChanged()));
|
||||||
|
|
||||||
|
// add archive manager
|
||||||
|
_archiveManager = new QXmppArchiveManager;
|
||||||
|
XmppClient::getInstance().getXMPPClient().addExtension(_archiveManager);
|
||||||
|
|
||||||
|
connect(_archiveManager, SIGNAL(archiveChatReceived(QXmppArchiveChat, QXmppResultSetReply)),
|
||||||
|
SLOT(archiveChatReceived(QXmppArchiveChat, QXmppResultSetReply)));
|
||||||
|
|
||||||
|
connect(_archiveManager, SIGNAL(archiveListReceived(QList<QXmppArchiveChat>, QXmppResultSetReply)),
|
||||||
|
SLOT(archiveListReceived(QList<QXmppArchiveChat>, QXmppResultSetReply)));
|
||||||
|
|
||||||
|
QXmppResultSetQuery rsmQuery;
|
||||||
|
rsmQuery.setMax(MAX_HISTORY_CHAT_MESSAGES);
|
||||||
|
_archiveManager->listCollections(publicChatRoom->jid(),
|
||||||
|
QDateTime::currentDateTime().addDays(-MAX_HISTORY_DAYS),
|
||||||
|
QDateTime::currentDateTime(),
|
||||||
|
rsmQuery);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
startTimerForTimeStamps();
|
startTimerForTimeStamps();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ChatWindow::archiveChatReceived(const QXmppArchiveChat &chat, const QXmppResultSetReply &rsmReply) {
|
||||||
|
foreach (const QXmppArchiveMessage &msg, chat.messages()) {
|
||||||
|
qDebug() << "message:" << qPrintable(msg.body());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void ChatWindow::archiveListReceived(const QList<QXmppArchiveChat> &chats, const QXmppResultSetReply &rsmReply) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
void ChatWindow::timeout() {
|
void ChatWindow::timeout() {
|
||||||
if (numMessagesAfterLastTimeStamp >= NUM_MESSAGES_TO_TIME_STAMP) {
|
if (numMessagesAfterLastTimeStamp >= NUM_MESSAGES_TO_TIME_STAMP) {
|
||||||
addTimeStamp();
|
addTimeStamp();
|
||||||
|
|
|
@ -26,6 +26,9 @@
|
||||||
#include <QXmppClient.h>
|
#include <QXmppClient.h>
|
||||||
#include <QXmppMessage.h>
|
#include <QXmppMessage.h>
|
||||||
|
|
||||||
|
#include "QXmppArchiveIq.h"
|
||||||
|
#include "QXmppArchiveManager.h"
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
namespace Ui {
|
namespace Ui {
|
||||||
|
@ -68,6 +71,7 @@ private:
|
||||||
QSystemTrayIcon _trayIcon;
|
QSystemTrayIcon _trayIcon;
|
||||||
QStringList _mentionSounds;
|
QStringList _mentionSounds;
|
||||||
QMediaPlayer _effectPlayer;
|
QMediaPlayer _effectPlayer;
|
||||||
|
QXmppArchiveManager* _archiveManager;
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void connected();
|
void connected();
|
||||||
|
@ -77,6 +81,10 @@ private slots:
|
||||||
void participantsChanged();
|
void participantsChanged();
|
||||||
void messageReceived(const QXmppMessage& message);
|
void messageReceived(const QXmppMessage& message);
|
||||||
void notificationClicked();
|
void notificationClicked();
|
||||||
|
|
||||||
|
|
||||||
|
void archiveListReceived(const QList<QXmppArchiveChat> &chats, const QXmppResultSetReply &rsmReply);
|
||||||
|
void archiveChatReceived(const QXmppArchiveChat &chat, const QXmppResultSetReply &rsmReply);
|
||||||
#endif
|
#endif
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue