summaryrefslogtreecommitdiffstats
path: root/api/logic/net/PasteUpload.h
diff options
context:
space:
mode:
authorPetr Mrázek <peterix@gmail.com>2016-04-10 15:53:05 +0200
committerPetr Mrázek <peterix@gmail.com>2016-05-01 00:00:14 +0200
commitb6d455a02bd338e9dc0faa09d4d8177ecd8d569a (patch)
tree41982bca1ede50049f2f8c7109dd18edeefde6d0 /api/logic/net/PasteUpload.h
parent47e37635f50c09b4f9a9ee7699e3120bab3e4088 (diff)
downloadMultiMC-b6d455a02bd338e9dc0faa09d4d8177ecd8d569a.tar
MultiMC-b6d455a02bd338e9dc0faa09d4d8177ecd8d569a.tar.gz
MultiMC-b6d455a02bd338e9dc0faa09d4d8177ecd8d569a.tar.lz
MultiMC-b6d455a02bd338e9dc0faa09d4d8177ecd8d569a.tar.xz
MultiMC-b6d455a02bd338e9dc0faa09d4d8177ecd8d569a.zip
NOISSUE reorganize and document libraries
Diffstat (limited to 'api/logic/net/PasteUpload.h')
-rw-r--r--api/logic/net/PasteUpload.h50
1 files changed, 50 insertions, 0 deletions
diff --git a/api/logic/net/PasteUpload.h b/api/logic/net/PasteUpload.h
new file mode 100644
index 00000000..06e3f955
--- /dev/null
+++ b/api/logic/net/PasteUpload.h
@@ -0,0 +1,50 @@
+#pragma once
+#include "tasks/Task.h"
+#include <QNetworkReply>
+#include <QBuffer>
+#include <memory>
+
+#include "multimc_logic_export.h"
+
+class MULTIMC_LOGIC_EXPORT PasteUpload : public Task
+{
+ Q_OBJECT
+public:
+ PasteUpload(QWidget *window, QString text, QString key = "public");
+ virtual ~PasteUpload();
+ QString pasteLink()
+ {
+ return m_pasteLink;
+ }
+ QString pasteID()
+ {
+ return m_pasteID;
+ }
+ uint32_t maxSize()
+ {
+ // 2MB for paste.ee - public
+ if(m_key == "public")
+ return 1024*1024*2;
+ // 12MB for paste.ee - with actual key
+ return 1024*1024*12;
+ }
+ bool validateText();
+protected:
+ virtual void executeTask();
+
+private:
+ bool parseResult(QJsonDocument doc);
+ QByteArray m_text;
+ QString m_error;
+ QWidget *m_window;
+ QString m_pasteID;
+ QString m_pasteLink;
+ QString m_key;
+ int m_textSize = 0;
+ QBuffer * buf = nullptr;
+ std::shared_ptr<QNetworkReply> m_reply;
+public
+slots:
+ void downloadError(QNetworkReply::NetworkError);
+ void downloadFinished();
+};