Hide button for file upload only if server actively disables it

parent abebde08
Pipeline #38791 passed with stage
in 2 minutes and 42 seconds
......@@ -50,11 +50,10 @@ UploadManager::UploadManager(QXmppClient *client, RosterManager* rosterManager,
{
client->addExtension(&m_manager);
connect(&m_manager, &QXmppUploadManager::serviceFoundChanged, this, &UploadManager::handleHttpFileUploadSupportedChanged);
connect(Kaidan::instance(), &Kaidan::sendFile, this, &UploadManager::sendFile);
connect(&m_manager, &QXmppUploadManager::serviceFoundChanged, this, [=]() {
Kaidan::instance()->serverFeaturesCache()->setHttpUploadSupported(m_manager.serviceFound());
});
connect(&m_manager, &QXmppUploadManager::uploadSucceeded,
this, &UploadManager::handleUploadSucceeded);
connect(&m_manager, &QXmppUploadManager::uploadFailed,
......@@ -142,6 +141,13 @@ void UploadManager::handleUploadSucceeded(const QXmppHttpUpload *upload)
emit Kaidan::instance()->transferCache()->removeJobRequested(originalMsg->id());
}
void UploadManager::handleHttpFileUploadSupportedChanged()
{
if (m_client->isConnected()) {
Kaidan::instance()->serverFeaturesCache()->setHttpUploadSupported(m_manager.serviceFound());
}
}
void UploadManager::handleUploadFailed(const QXmppHttpUpload *upload)
{
qDebug() << "[client] [UploadManager] A file upload has failed.";
......
......@@ -68,6 +68,15 @@ public slots:
void handleUploadFailed(const QXmppHttpUpload *upload);
void handleUploadSucceeded(const QXmppHttpUpload *upload);
private slots:
/**
* Called when the HTTP File Upload support changed.
*
* The server feature state for HTTP File Upload is only changed when the server disables it, not on disconnect.
* That way, the last known state can be cached while being offline and queuing a file for being sent as soon as Kaidan is online again can be offered to the user even if Kaidan is not connected to the user's server.
*/
void handleHttpFileUploadSupportedChanged();
private:
QXmppClient *m_client;
QXmppUploadManager m_manager;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment