Skip to content
This repository has been archived by the owner on May 16, 2020. It is now read-only.

Commit

Permalink
Added networking config initialization
Browse files Browse the repository at this point in the history
  • Loading branch information
Antti Lamminsalo committed Mar 17, 2016
1 parent bd38ab6 commit 5cd64ae
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 9 deletions.
2 changes: 2 additions & 0 deletions orion.pro
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
3 changes: 2 additions & 1 deletion src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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...";
Expand Down
10 changes: 10 additions & 0 deletions src/network/networkmanager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<QSslError>)), this, SLOT(handleSslErrors(QNetworkReply*,QList<QSslError>)));

Expand All @@ -18,6 +22,7 @@ NetworkManager::~NetworkManager()
{
qDebug() << "Destroyer: NetworkManager";
operation->deleteLater();
conf->deleteLater();
}

void NetworkManager::getStreams(const QString &url)
Expand Down Expand Up @@ -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;
Expand Down
4 changes: 3 additions & 1 deletion src/network/networkmanager.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

#include <QObject>
#include <QtNetwork/QNetworkAccessManager>
#include <QNetworkConfigurationManager>
#include <QUrl>
#include <QtNetwork/QNetworkReply>
#include <QJsonDocument>
Expand Down Expand Up @@ -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<Channel *>&);
Expand Down Expand Up @@ -77,6 +78,7 @@ private slots:

private:
QNetworkAccessManager *operation;
QNetworkConfigurationManager *conf;
};

#endif // NETWORKMANAGER_H
6 changes: 1 addition & 5 deletions src/notification/notificationmanager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -40,8 +38,6 @@ NotificationManager::~NotificationManager()
timer->stop();
delete timer;

net->deleteLater();

#ifdef Q_OS_WIN
hiddenWindow->close();
delete hiddenWindow;
Expand Down
4 changes: 2 additions & 2 deletions src/notification/notificationmanager.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
#include <QQmlApplicationEngine>
#include <QQmlComponent>
#include <QObject>
#include <QNetworkAccessManager>

#ifdef Q_OS_WIN
#include <QQuickWindow>
Expand All @@ -23,7 +22,7 @@ class NotificationManager: public QObject
{
Q_OBJECT
public:
NotificationManager(QQmlApplicationEngine *engine);
NotificationManager(QQmlApplicationEngine *engine, QNetworkAccessManager *nm);
virtual ~NotificationManager();

private slots:
Expand All @@ -34,6 +33,7 @@ public slots:

private:
QQmlApplicationEngine *engine;

QNetworkAccessManager *net;

QTimer *timer;
Expand Down

0 comments on commit 5cd64ae

Please sign in to comment.