refactor: organize a little more the code in launcher/net/

This also reduces some code duplication by using some Task logic in
NetAction.
This commit is contained in:
flow
2022-04-21 22:12:14 -03:00
parent 649b8ac7c6
commit 8c8eabf7ac
19 changed files with 435 additions and 469 deletions

View File

@ -27,7 +27,7 @@ class Download : public NetAction
{
Q_OBJECT
public: /* types */
public:
typedef shared_qobject_ptr<class Download> Ptr;
enum class Option
{
@ -36,7 +36,7 @@ public: /* types */
};
Q_DECLARE_FLAGS(Options, Option)
protected: /* con/des */
protected:
explicit Download();
public:
virtual ~Download(){};
@ -44,16 +44,16 @@ public:
static Download::Ptr makeByteArray(QUrl url, QByteArray *output, Options options = Option::NoOptions);
static Download::Ptr makeFile(QUrl url, QString path, Options options = Option::NoOptions);
public: /* methods */
public:
QString getTargetFilepath()
{
return m_target_path;
}
void addValidator(Validator * v);
bool abort() override;
bool canAbort() override;
bool canAbort() const override { return true; };
private: /* methods */
private:
bool handleRedirect();
protected slots:
@ -64,9 +64,9 @@ protected slots:
void downloadReadyRead() override;
public slots:
void startImpl() override;
void executeTask() override;
private: /* data */
private:
// FIXME: remove this, it has no business being here.
QString m_target_path;
std::unique_ptr<Sink> m_sink;