0

I'm making one xmpp client and I have a lot doubts in extensions ..

I did need get a list of old messages with one user, so .. I'm using the QXmppArchiveManager class for that. So I make one class like that:

...

class QXmppArchiveManager;
class MessageController : public QXmppClient
{
...

private:
    QNetworkAccessManager *nam_;
    QXmppClient *xmppClient_;
    QXmppArchiveManager *archiveMng_;
    QDateTime m_startDate;
    QDateTime m_endDate;

protected slots:
    virtual void onConnected();
    virtual void onMessageReceived(const QXmppMessage &);
    virtual void archiveListReceived(const QList<QXmppArchiveChat> &chats, const QXmppResultSetReply &rsmReply);
}

And implements

...
void MessageController::onConnected() //before client connects listener...
{

    QXmppResultSetQuery rsmQuery;
    rsmQuery.setMax(0);
    m_startDate = QDateTime::currentDateTime().addDays(-201);
    m_endDate = QDateTime::currentDateTime();

    archiveMng_->listCollections("", m_startDate, m_endDate, rsmQuery);

}

void MessageController::connect()
{

    xmppClient_ = new QXmppClient();
    QObject::connect( xmppClient_, SIGNAL( connected() ), this, SLOT( onConnected() ) );
    QObject::connect( xmppClient_, SIGNAL( messageReceived( QXmppMessage ) ), this, SLOT( onMessageReceived( QXmppMessage ) ) );

    archiveMng_ = new QXmppArchiveManager;
    xmppClient_->addExtension(archiveMng_); 

    QObject::connect(archiveMng_, SIGNAL(archiveChatReceived(QXmppArchiveChat, QXmppResultSetReply)),
                    SLOT(archiveChatReceived(QXmppArchiveChat, QXmppResultSetReply))); 

    QObject::connect(archiveMng_, SIGNAL(archiveListReceived(QList<QXmppArchiveChat>, QXmppResultSetReply)),
                SLOT(archiveListReceived(QList<QXmppArchiveChat>, QXmppResultSetReply))); 

    xmppClient_->logger()->setLoggingType( QXmppLogger::StdoutLogging );  

    QXmppConfiguration config;

    config.setDomain("(censored)");
    config.setHost("(censored)");
    config.setPort(5222);
    config.setUser((censored));
    config.setPassword((censored));
    config.setResource("Android-Client");

    xmppClient_->connectToServer( config );

}

void MessageController::archiveChatReceived(const QXmppArchiveChat &chat, const QXmppResultSetReply &rsmReply)
{
    qDebug() << "archiveChatReceived";
}

void MessageController::archiveListReceived(const QList<QXmppArchiveChat> &chats, const QXmppResultSetReply &rsmReply)
{
    qDebug() << "archiveListReceived";
}

The problem is ... this code not called this listeners, in this case not call "archiveListReceived".

How I can fix that ?

Thanks

f4root
  • 475
  • 1
  • 4
  • 15
  • How does that relate to `QML`? – folibis Sep 22 '15 at 22:43
  • I did this example calling connect method from qml screen file.. but I don't using this in here.. so I drop this tag.. so ... do you know some answer about this case ? – f4root Sep 23 '15 at 04:55

1 Answers1

0

I found the problem, in this case my openfire xmpp server not working for archive, so ... I'm install the open-archive plugin for it!

f4root
  • 475
  • 1
  • 4
  • 15
  • yep that's a bit crap with QXmpp, you won't get notified, when something breaks... I've planned to implement an API based on QFutures now, so that this problem could be solved. – LNJ Aug 07 '20 at 14:04