From 6c261459cfb4584a5f303147d9525b9a0467d4e7 Mon Sep 17 00:00:00 2001 From: Mm2PL Date: Tue, 22 Oct 2019 17:21:46 +0200 Subject: [PATCH] Renamed TypedBytes to RawImageData, type to format. FeelsGoodMan Clap --- src/util/NuulsUploader.cpp | 13 ++++++------- src/util/NuulsUploader.hpp | 6 +++--- 2 files changed, 9 insertions(+), 10 deletions(-) diff --git a/src/util/NuulsUploader.cpp b/src/util/NuulsUploader.cpp index 07b0b4379..cbf81beda 100644 --- a/src/util/NuulsUploader.cpp +++ b/src/util/NuulsUploader.cpp @@ -44,10 +44,9 @@ boost::optional convertToPng(QImage image) namespace chatterino { // These variables are only used from the main thread. bool isUploading = false; +std::queue uploadQueue; -std::queue uploadQueue; - -void uploadImageToNuuls(TypedBytes imageData, ChannelPtr channel, +void uploadImageToNuuls(RawImageData imageData, ChannelPtr channel, ResizingTextEdit &textEdit) { const char *boundary = "thisistheboudaryasd"; @@ -59,13 +58,13 @@ void uploadImageToNuuls(TypedBytes imageData, ChannelPtr channel, QHttpPart part = QHttpPart(); part.setBody(imageData.data); part.setHeader(QNetworkRequest::ContentTypeHeader, - QString("image/%1").arg(imageData.type)); + QString("image/%1").arg(imageData.format)); part.setHeader(QNetworkRequest::ContentLengthHeader, QVariant(imageData.data.length())); part.setHeader( QNetworkRequest::ContentDispositionHeader, QString("form-data; name=\"attachment\"; filename=\"control_v.%1\"") - .arg(imageData.type)); + .arg(imageData.format)); payload->setBoundary(boundary); payload->append(part); NetworkRequest(url, NetworkRequestType::Post) @@ -163,7 +162,7 @@ void upload(const QMimeData *source, ChannelPtr channel, boost::optional imageData = convertToPng(img); if (imageData) { - TypedBytes data = {imageData.get(), "png"}; + RawImageData data = {imageData.get(), "png"}; uploadQueue.push(data); } else @@ -186,7 +185,7 @@ void upload(const QMimeData *source, ChannelPtr channel, makeSystemMessage(QString("Failed to open file. :("))); return; } - TypedBytes data = {file.readAll(), "gif"}; + RawImageData data = {file.readAll(), "gif"}; uploadQueue.push(data); file.close(); // file.readAll() => might be a bit big but it /should/ work diff --git a/src/util/NuulsUploader.hpp b/src/util/NuulsUploader.hpp index 675d9c0ed..192de31f6 100644 --- a/src/util/NuulsUploader.hpp +++ b/src/util/NuulsUploader.hpp @@ -5,13 +5,13 @@ #include namespace chatterino { -struct TypedBytes { +struct RawImageData { QByteArray data; - QString type; + QString format; }; void upload(QByteArray imageData, ChannelPtr channel, ResizingTextEdit &textEdit, std::string format); -void upload(TypedBytes imageData, ChannelPtr channel, +void upload(RawImageData imageData, ChannelPtr channel, ResizingTextEdit &textEdit); void upload(const QMimeData *source, ChannelPtr channel, ResizingTextEdit &outputTextEdit);