From 5cd64ae2ade3e336c2f27e8bb177a0da1869fd82 Mon Sep 17 00:00:00 2001 From: Antti Lamminsalo Date: Thu, 17 Mar 2016 21:17:29 +0200 Subject: [PATCH] Added networking config initialization --- orion.pro | 2 ++ src/main.cpp | 3 ++- src/network/networkmanager.cpp | 10 ++++++++++ src/network/networkmanager.h | 4 +++- src/notification/notificationmanager.cpp | 6 +----- src/notification/notificationmanager.h | 4 ++-- 6 files changed, 20 insertions(+), 9 deletions(-) diff --git a/orion.pro b/orion.pro index 864861d..4f242bd 100644 --- a/orion.pro +++ b/orion.pro @@ -125,8 +125,10 @@ win32: { macx: { LIBS += -framework Foundation LIBS += -framework AppKit + HEADERS += src/notification/notificationsender.h OBJECTIVE_SOURCES += src/notification/NotificationSender.mm + INCLUDEPATH += /System/Library/Frameworks/Foundation.framework/Versions/C/Headers INCLUDEPATH += /System/Library/Frameworks/AppKit.framework/Versions/C/Headers diff --git a/src/main.cpp b/src/main.cpp index fe463b0..c1b9949 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -42,6 +42,7 @@ int main(int argc, char *argv[]) QObject::connect(tray, SIGNAL(closeEventTriggered()), &app, SLOT(quit())); + //Prime network manager NetworkManager *netman = new NetworkManager(); //Create channels manager @@ -96,7 +97,7 @@ int main(int argc, char *argv[]) engine.load(QUrl("qrc:/main.qml")); //Set up notifications - NotificationManager *notificationManager = new NotificationManager(&engine); + NotificationManager *notificationManager = new NotificationManager(&engine, netman->getManager()); QObject::connect(cman, SIGNAL(pushNotification(QString,QString,QString)), notificationManager, SLOT(pushNotification(QString,QString,QString))); qDebug() << "Starting window..."; diff --git a/src/network/networkmanager.cpp b/src/network/networkmanager.cpp index 2ab2f7f..c9699b1 100644 --- a/src/network/networkmanager.cpp +++ b/src/network/networkmanager.cpp @@ -7,6 +7,10 @@ NetworkManager::NetworkManager() { operation = new QNetworkAccessManager(); + //Set configuration + conf = new QNetworkConfigurationManager(); + operation->setConfiguration(conf->defaultConfiguration()); + //SSL errors handle (down the drain) connect(operation, SIGNAL(sslErrors(QNetworkReply*,QList)), this, SLOT(handleSslErrors(QNetworkReply*,QList))); @@ -18,6 +22,7 @@ NetworkManager::~NetworkManager() { qDebug() << "Destroyer: NetworkManager"; operation->deleteLater(); + conf->deleteLater(); } void NetworkManager::getStreams(const QString &url) @@ -137,6 +142,11 @@ void NetworkManager::getBroadcastPlaybackStream(const QString &vod) connect(reply, SIGNAL(finished()), this, SLOT(streamExtractReply())); } +QNetworkAccessManager *NetworkManager::getManager() const +{ + return operation; +} + void NetworkManager::getM3U8Data(const QString &url, M3U8TYPE type) { QNetworkRequest request; diff --git a/src/network/networkmanager.h b/src/network/networkmanager.h index f7dd694..7a3692e 100644 --- a/src/network/networkmanager.h +++ b/src/network/networkmanager.h @@ -3,6 +3,7 @@ #include #include +#include #include #include #include @@ -45,7 +46,7 @@ class NetworkManager: public QObject void getBroadcasts(const QString channelName, quint32 offset, quint32 limit); void getBroadcastPlaybackStream(const QString &vod); - QNetworkAccessManager *getOperation() const; + QNetworkAccessManager *getManager() const; signals: void allStreamsOperationFinished(const QList&); @@ -77,6 +78,7 @@ private slots: private: QNetworkAccessManager *operation; + QNetworkConfigurationManager *conf; }; #endif // NETWORKMANAGER_H diff --git a/src/notification/notificationmanager.cpp b/src/notification/notificationmanager.cpp index c5f80ca..3694181 100644 --- a/src/notification/notificationmanager.cpp +++ b/src/notification/notificationmanager.cpp @@ -7,10 +7,8 @@ #endif -NotificationManager::NotificationManager(QQmlApplicationEngine *engine) +NotificationManager::NotificationManager(QQmlApplicationEngine *engine, QNetworkAccessManager *nm) : net(nm) { - net = new QNetworkAccessManager(); - net->connectToHost("http://static-cdn.jtvnw.net"); currentObject = 0; queue.clear(); @@ -40,8 +38,6 @@ NotificationManager::~NotificationManager() timer->stop(); delete timer; - net->deleteLater(); - #ifdef Q_OS_WIN hiddenWindow->close(); delete hiddenWindow; diff --git a/src/notification/notificationmanager.h b/src/notification/notificationmanager.h index 95f6404..302ff8d 100644 --- a/src/notification/notificationmanager.h +++ b/src/notification/notificationmanager.h @@ -7,7 +7,6 @@ #include #include #include -#include #ifdef Q_OS_WIN #include @@ -23,7 +22,7 @@ class NotificationManager: public QObject { Q_OBJECT public: - NotificationManager(QQmlApplicationEngine *engine); + NotificationManager(QQmlApplicationEngine *engine, QNetworkAccessManager *nm); virtual ~NotificationManager(); private slots: @@ -34,6 +33,7 @@ public slots: private: QQmlApplicationEngine *engine; + QNetworkAccessManager *net; QTimer *timer;