mirror of
https://github.com/PrismLauncher/PrismLauncher.git
synced 2026-06-29 01:54:20 +03:00
remove duplicate code from net folder
Signed-off-by: Trial97 <alexandru.tripon97@gmail.com>
This commit is contained in:
parent
330c95e55b
commit
c07260e836
28 changed files with 72 additions and 189 deletions
|
|
@ -46,7 +46,7 @@
|
|||
#include <memory>
|
||||
|
||||
#include "BuildConfig.h"
|
||||
#include "net/StaticHeaderProxy.h"
|
||||
#include "net/RawHeaderProxy.h"
|
||||
|
||||
Net::NetRequest::Ptr ImgurAlbumCreation::make(std::shared_ptr<ImgurAlbumCreation::Result> output, QList<ScreenShot::Ptr> screenshots)
|
||||
{
|
||||
|
|
@ -54,6 +54,10 @@ Net::NetRequest::Ptr ImgurAlbumCreation::make(std::shared_ptr<ImgurAlbumCreation
|
|||
up->m_url = BuildConfig.IMGUR_BASE_URL + "album";
|
||||
up->m_sink.reset(new Sink(output));
|
||||
up->m_screenshots = screenshots;
|
||||
up->addHeaderProxy(new Net::RawHeaderProxy(
|
||||
QList<Net::HeaderPair>{ { "Content-Type", "application/x-www-form-urlencoded" },
|
||||
{ "Authorization", QString("Client-ID %1").arg(BuildConfig.IMGUR_CLIENT_ID).toUtf8() },
|
||||
{ "Accept", "application/json" } }));
|
||||
return up;
|
||||
}
|
||||
|
||||
|
|
@ -67,16 +71,6 @@ QNetworkReply* ImgurAlbumCreation::getReply(QNetworkRequest& request)
|
|||
return m_network->post(request, data);
|
||||
};
|
||||
|
||||
void ImgurAlbumCreation::init()
|
||||
{
|
||||
qDebug() << "Setting up imgur upload";
|
||||
auto api_headers = new Net::StaticHeaderProxy(
|
||||
QList<Net::HeaderPair>{ { "Content-Type", "application/x-www-form-urlencoded" },
|
||||
{ "Authorization", QString("Client-ID %1").arg(BuildConfig.IMGUR_CLIENT_ID).toUtf8() },
|
||||
{ "Accept", "application/json" } });
|
||||
addHeaderProxy(api_headers);
|
||||
}
|
||||
|
||||
auto ImgurAlbumCreation::Sink::init(QNetworkRequest& request) -> Task::State
|
||||
{
|
||||
m_output.clear();
|
||||
|
|
|
|||
|
|
@ -67,8 +67,6 @@ class ImgurAlbumCreation : public Net::NetRequest {
|
|||
static NetRequest::Ptr make(std::shared_ptr<Result> output, QList<ScreenShot::Ptr> screenshots);
|
||||
QNetworkReply* getReply(QNetworkRequest& request) override;
|
||||
|
||||
void init() override;
|
||||
|
||||
private:
|
||||
QList<ScreenShot::Ptr> m_screenshots;
|
||||
};
|
||||
|
|
|
|||
|
|
@ -36,7 +36,7 @@
|
|||
|
||||
#include "ImgurUpload.h"
|
||||
#include "BuildConfig.h"
|
||||
#include "net/StaticHeaderProxy.h"
|
||||
#include "net/RawHeaderProxy.h"
|
||||
|
||||
#include <QDebug>
|
||||
#include <QFile>
|
||||
|
|
@ -47,14 +47,6 @@
|
|||
#include <QNetworkRequest>
|
||||
#include <QUrl>
|
||||
|
||||
void ImgurUpload::init()
|
||||
{
|
||||
qDebug() << "Setting up imgur upload";
|
||||
auto api_headers = new Net::StaticHeaderProxy(QList<Net::HeaderPair>{
|
||||
{ "Authorization", QString("Client-ID %1").arg(BuildConfig.IMGUR_CLIENT_ID).toUtf8() }, { "Accept", "application/json" } });
|
||||
addHeaderProxy(api_headers);
|
||||
}
|
||||
|
||||
QNetworkReply* ImgurUpload::getReply(QNetworkRequest& request)
|
||||
{
|
||||
auto file = new QFile(m_fileInfo.absoluteFilePath(), this);
|
||||
|
|
@ -125,5 +117,7 @@ Net::NetRequest::Ptr ImgurUpload::make(ScreenShot::Ptr m_shot)
|
|||
auto up = makeShared<ImgurUpload>(m_shot->m_file);
|
||||
up->m_url = std::move(BuildConfig.IMGUR_BASE_URL + "image");
|
||||
up->m_sink.reset(new Sink(m_shot));
|
||||
up->addHeaderProxy(new Net::RawHeaderProxy(QList<Net::HeaderPair>{
|
||||
{ "Authorization", QString("Client-ID %1").arg(BuildConfig.IMGUR_CLIENT_ID).toUtf8() }, { "Accept", "application/json" } }));
|
||||
return up;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -62,8 +62,6 @@ class ImgurUpload : public Net::NetRequest {
|
|||
|
||||
static NetRequest::Ptr make(ScreenShot::Ptr m_shot);
|
||||
|
||||
void init() override;
|
||||
|
||||
private:
|
||||
virtual QNetworkReply* getReply(QNetworkRequest&) override;
|
||||
const QFileInfo m_fileInfo;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue