Init file sending.

This commit is contained in:
Black Hat
2018-07-16 22:05:34 +08:00
parent 4ef063ea82
commit 731cef3c77
7 changed files with 34 additions and 7 deletions

View File

@@ -79,8 +79,12 @@ void Controller::reconnect() {
m_connection->connectWithToken(userID, token, "");
}
void Controller::postFile(QMatrixClient::Room* room,
const QUrl& localFilename) {
// auto job = m_connection->uploadFile(localFilename.toLocalFile());
// room->fileTransferInfo(localFilename.fileName())
void Controller::postFile(QMatrixClient::Room* room, const QUrl& localFile,
const QUrl& mxcUrl) {
QJsonObject json{{"body", localFile.fileName()},
{"filename", localFile.fileName()},
{"url", mxcUrl.url()}};
room->postMessage(QMatrixClient::RoomMessageEvent{
localFile.fileName(), "m.file",
new QMatrixClient::EventContent::FileContent(json)});
}

View File

@@ -97,7 +97,8 @@ class Controller : public QObject {
void errorOccured();
public slots:
void postFile(QMatrixClient::Room* room, const QUrl& localFilename);
void postFile(QMatrixClient::Room* room, const QUrl& localFile,
const QUrl& mxcUrl);
};
#endif // CONTROLLER_H

View File

@@ -273,8 +273,9 @@ QVariant MessageEventModel::data(const QModelIndex& index, int role) const {
return "notice";
case MessageEventType::Image:
return "image";
case MessageEventType::File:
case MessageEventType::Audio:
// return "audio";
case MessageEventType::File:
case MessageEventType::Video:
return "file";
default: