Verified Commit def9df70 authored by Linus Jahn's avatar Linus Jahn

media-sharing: Only enable if service discovered

parent 701e9b9e
......@@ -152,6 +152,8 @@ void ClientThread::run()
rosterManager, &RosterManager::addContact);
connect(uploadHandler, &UploadHandler::uploadProgressMade,
kaidan, &Kaidan::uploadProgressMade);
connect(uploadHandler, &UploadHandler::uploadServiceFound,
kaidan, &Kaidan::enableHttpUpload);
connect(this, &ClientThread::removeContactRequested,
rosterManager, &RosterManager::removeContact);
connect(kaidan, &Kaidan::vCardRequested, [=](QString jid) {
......
......@@ -108,6 +108,12 @@ Kaidan::Kaidan(QGuiApplication *app, bool enableLogging, QObject *parent) : QObj
openUriCache = "";
});
}
// on disconnection, disable file upload
if (state == ConnectionState::StateDisconnected) {
hasHttpUpload = false;
emit httpUploadChanged();
}
});
}
......
......@@ -75,6 +75,7 @@ class Kaidan : public QObject
Q_PROPERTY(QString jidResource READ getJidResource WRITE setJidResource NOTIFY jidResourceChanged)
Q_PROPERTY(QString password READ getPassword WRITE setPassword NOTIFY passwordChanged)
Q_PROPERTY(QString chatPartner READ getChatPartner WRITE setChatPartner NOTIFY chatPartnerChanged)
Q_PROPERTY(bool httpUploadEnabled READ getHttpUploadEnabled NOTIFY httpUploadChanged)
public:
/**
......@@ -277,6 +278,14 @@ public:
*/
Q_INVOKABLE void copyToClipboard(QString text);
/**
* Returns true, if XEP-0363: HTTP File Upload was discovered
*/
bool getHttpUploadEnabled()
{
return hasHttpUpload;
}
signals:
void rosterModelChanged();
void messageModelChanged();
......@@ -364,6 +373,11 @@ signals:
*/
void uploadProgressMade(QString msgId, unsigned long sent, unsigned long total);
/**
* XEP-0363: HTTP File Upload was discovered (or isn't working anymore)
*/
void httpUploadChanged();
public slots:
/**
* Receives messages from another instance of the application
......@@ -374,6 +388,15 @@ public slots:
addOpenUri(msg);
}
/**
* Enables XEP-0363: HTTP File Upload
*/
void enableHttpUpload()
{
hasHttpUpload = true;
emit httpUploadChanged();
}
private:
void connectDatabases();
......@@ -390,6 +413,8 @@ private:
QString chatPartner;
QString openUriCache;
bool hasHttpUpload = false;
};
#endif
......@@ -200,6 +200,7 @@ void UploadHandler::handleUploadServiceRemoved(const gloox::JID &jid)
void UploadHandler::handleUploadServiceAdded(const gloox::JID &jid,
unsigned long maxFileSize)
{
emit uploadServiceFound();
}
void UploadHandler::handleFileSizeLimitChanged(unsigned long maxFileSize)
......
......@@ -76,6 +76,11 @@ signals:
*/
void uploadProgressMade(QString msgId, unsigned long sent, unsigned long total);
/**
* XEP-0363: HTTP File Upload service has been found
*/
void uploadServiceFound();
public slots:
/**
* Starts uploading a file
......
......@@ -158,6 +158,7 @@ Kirigami.ScrollablePage {
Controls.ToolButton {
id: attachButton
visible: kaidan.httpUploadEnabled
Layout.preferredWidth: Kirigami.Units.gridUnit * 3
Layout.preferredHeight: Kirigami.Units.gridUnit * 3
padding: 0
......
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