diff options
author | Petr Mrázek <peterix@gmail.com> | 2013-09-07 04:00:58 +0200 |
---|---|---|
committer | Petr Mrázek <peterix@gmail.com> | 2013-09-07 04:00:58 +0200 |
commit | 6892c11e9f287dcfb1e698f8f46233a01fb7abb6 (patch) | |
tree | ee94607e92bcf39faef7f35842499fafbb2e270f /logic/net | |
parent | 3f30055afe757637ae865b2adc7cf021edd9b8b5 (diff) | |
download | MultiMC-6892c11e9f287dcfb1e698f8f46233a01fb7abb6.tar MultiMC-6892c11e9f287dcfb1e698f8f46233a01fb7abb6.tar.gz MultiMC-6892c11e9f287dcfb1e698f8f46233a01fb7abb6.tar.lz MultiMC-6892c11e9f287dcfb1e698f8f46233a01fb7abb6.tar.xz MultiMC-6892c11e9f287dcfb1e698f8f46233a01fb7abb6.zip |
Move a good chunk of the singleton objects into a new QApplication subclass.
Diffstat (limited to 'logic/net')
-rw-r--r-- | logic/net/DownloadJob.cpp | 6 | ||||
-rw-r--r-- | logic/net/NetWorker.cpp | 30 | ||||
-rw-r--r-- | logic/net/NetWorker.h | 31 |
3 files changed, 3 insertions, 64 deletions
diff --git a/logic/net/DownloadJob.cpp b/logic/net/DownloadJob.cpp index b87d3dc9..cad9ae72 100644 --- a/logic/net/DownloadJob.cpp +++ b/logic/net/DownloadJob.cpp @@ -1,6 +1,6 @@ #include "DownloadJob.h" #include "pathutils.h" -#include "NetWorker.h" +#include "MultiMC.h" Download::Download (QUrl url, QString target_path, QString expected_md5 ) :Job() @@ -49,8 +49,8 @@ void Download::start() QNetworkRequest request ( m_url ); request.setRawHeader(QString("If-None-Match").toLatin1(), m_expected_md5.toLatin1()); - auto &worker = NetWorker::qnam(); - QNetworkReply * rep = worker.get ( request ); + auto worker = MMC->qnam(); + QNetworkReply * rep = worker->get ( request ); m_reply = QSharedPointer<QNetworkReply> ( rep, &QObject::deleteLater ); connect ( rep, SIGNAL ( downloadProgress ( qint64,qint64 ) ), SLOT ( downloadProgress ( qint64,qint64 ) ) ); diff --git a/logic/net/NetWorker.cpp b/logic/net/NetWorker.cpp deleted file mode 100644 index c5943348..00000000 --- a/logic/net/NetWorker.cpp +++ /dev/null @@ -1,30 +0,0 @@ -#include "NetWorker.h" -#include <QThreadStorage> - -class NetWorker::Private -{ -public: - QNetworkAccessManager manager; -}; - -NetWorker::NetWorker ( QObject* parent ) : QObject ( parent ) -{ - d = new Private(); -} - -QNetworkAccessManager& NetWorker::qnam() -{ - auto & w = worker(); - return w.d->manager; -} - - -NetWorker& NetWorker::worker() -{ - static QThreadStorage<NetWorker *> storage; - if (!storage.hasLocalData()) - { - storage.setLocalData(new NetWorker()); - } - return *storage.localData(); -} diff --git a/logic/net/NetWorker.h b/logic/net/NetWorker.h deleted file mode 100644 index cf7e72e1..00000000 --- a/logic/net/NetWorker.h +++ /dev/null @@ -1,31 +0,0 @@ -/* - _.ooo-._ - .OOOP _ '. - dOOOO (_) \ - OOOOOb | - OOOOOOb. | - OOOOOOOOb | - YOO(_)OOO / - 'OOOOOY _.' - '""""'' -*/ -#pragma once - -#include <QNetworkAccessManager> -#include <QUrl> - -class NetWorker : public QObject -{ - Q_OBJECT -public: - // for high level access to the sevices (preferred) - static NetWorker &worker(); - // for low-level access to the network manager object - static QNetworkAccessManager &qnam(); -public: - -private: - explicit NetWorker ( QObject* parent = 0 ); - class Private; - Private * d; -};
\ No newline at end of file |