Commit 738b9984 authored by LNJ's avatar LNJ 💬

UploadManager: Accept not only local file urls (e.g. also content:)

This is required for the android `content:`-URLs.
parent 9722fe11
Pipeline #6614 passed with stages
in 15 minutes and 50 seconds
......@@ -320,7 +320,7 @@ signals:
/**
* Upload and send file
*/
void sendFile(QString jid, QString filePath, QString message);
void sendFile(const QString &jid, const QUrl &fileUrl, const QString &body);
/**
* Add a contact to your roster
......
......@@ -66,7 +66,7 @@ UploadManager::UploadManager(Kaidan *kaidan, QXmppClient *client, MessageModel *
this, &UploadManager::handleUploadFailed);
}
void UploadManager::sendFile(QString jid, QString fileUrl, QString body)
void UploadManager::sendFile(const QString &jid, const QUrl &fileUrl, const QString &body)
{
// TODO: Add offline media message cache and send when connnected again
if (client->state() != QXmppClient::ConnectedState) {
......@@ -80,7 +80,13 @@ void UploadManager::sendFile(QString jid, QString fileUrl, QString body)
qDebug() << "[client] [UploadManager] Adding upload for file:" << fileUrl;
QFileInfo file(QUrl(fileUrl).toLocalFile());
QFileInfo file;
if (fileUrl.isLocalFile())
file = QFileInfo(fileUrl.toLocalFile());
else
// this is used for android's content:/image:-URLs
file = QFileInfo(fileUrl.toString());
const QXmppHttpUpload* upload = manager.uploadFile(file);
QMimeType mimeType = QMimeDatabase().mimeTypeForFile(file);
......
......@@ -72,7 +72,7 @@ public slots:
/**
* Starts uploading a file
*/
void sendFile(QString jid, QString filePath, QString message);
void sendFile(const QString &jid, const QUrl &fileUrl, const QString &body);
void handleUploadFailed(const QXmppHttpUpload *upload);
void handleUploadSucceeded(const QXmppHttpUpload *upload);
......
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