Added XMPP archive manager

This commit is contained in:
Stojce Slavkovski 2014-04-29 20:40:12 +02:00
parent d24b55871f
commit 029e20edda
3 changed files with 39 additions and 1 deletions

View file

@ -21,7 +21,7 @@ const QString DEFAULT_CHAT_ROOM = "public@public-chat.highfidelity.io";
XmppClient::XmppClient() :
_xmppClient(),
_xmppMUCManager()
{
{
AccountManager& accountManager = AccountManager::getInstance();
connect(&accountManager, SIGNAL(accessTokenChanged()), this, SLOT(connectToServer()));
connect(&accountManager, SIGNAL(logoutComplete()), this, SLOT(disconnectFromServer()));

View file

@ -29,6 +29,8 @@
#include <QMessageBox>
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 regexHifiLinks("([#@]\\S+)");
@ -227,10 +229,38 @@ void ChatWindow::connected() {
#ifdef HAVE_QXMPP
const QXmppMucRoom* publicChatRoom = XmppClient::getInstance().getPublicChatRoom();
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
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() {
if (numMessagesAfterLastTimeStamp >= NUM_MESSAGES_TO_TIME_STAMP) {
addTimeStamp();

View file

@ -26,6 +26,9 @@
#include <QXmppClient.h>
#include <QXmppMessage.h>
#include "QXmppArchiveIq.h"
#include "QXmppArchiveManager.h"
#endif
namespace Ui {
@ -68,6 +71,7 @@ private:
QSystemTrayIcon _trayIcon;
QStringList _mentionSounds;
QMediaPlayer _effectPlayer;
QXmppArchiveManager* _archiveManager;
private slots:
void connected();
@ -77,6 +81,10 @@ private slots:
void participantsChanged();
void messageReceived(const QXmppMessage& message);
void notificationClicked();
void archiveListReceived(const QList<QXmppArchiveChat> &chats, const QXmppResultSetReply &rsmReply);
void archiveChatReceived(const QXmppArchiveChat &chat, const QXmppResultSetReply &rsmReply);
#endif
};