Moved Updater to common ostproto lib, Updater sends UserAgent
This commit is contained in:
parent
daba488d71
commit
bdbbd8f0a1
@ -58,7 +58,6 @@ HEADERS += \
|
|||||||
streamconfigdialog.h \
|
streamconfigdialog.h \
|
||||||
streamlistdelegate.h \
|
streamlistdelegate.h \
|
||||||
streammodel.h \
|
streammodel.h \
|
||||||
updater.h \
|
|
||||||
variablefieldswidget.h
|
variablefieldswidget.h
|
||||||
|
|
||||||
FORMS += \
|
FORMS += \
|
||||||
@ -100,7 +99,6 @@ SOURCES += \
|
|||||||
streamconfigdialog.cpp \
|
streamconfigdialog.cpp \
|
||||||
streamlistdelegate.cpp \
|
streamlistdelegate.cpp \
|
||||||
streammodel.cpp \
|
streammodel.cpp \
|
||||||
updater.cpp \
|
|
||||||
variablefieldswidget.cpp
|
variablefieldswidget.cpp
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
TEMPLATE = lib
|
TEMPLATE = lib
|
||||||
CONFIG += qt staticlib
|
CONFIG += qt staticlib
|
||||||
QT -= gui
|
QT -= gui
|
||||||
QT += network script
|
QT += network script xml
|
||||||
LIBS += \
|
LIBS += \
|
||||||
-lprotobuf
|
-lprotobuf
|
||||||
|
|
||||||
@ -47,6 +47,7 @@ HEADERS = \
|
|||||||
protocollist.h \
|
protocollist.h \
|
||||||
protocollistiterator.h \
|
protocollistiterator.h \
|
||||||
streambase.h \
|
streambase.h \
|
||||||
|
updater.h \
|
||||||
|
|
||||||
HEADERS += \
|
HEADERS += \
|
||||||
mac.h \
|
mac.h \
|
||||||
@ -85,6 +86,7 @@ SOURCES = \
|
|||||||
protocollist.cpp \
|
protocollist.cpp \
|
||||||
protocollistiterator.cpp \
|
protocollistiterator.cpp \
|
||||||
streambase.cpp \
|
streambase.cpp \
|
||||||
|
updater.cpp \
|
||||||
|
|
||||||
SOURCES += \
|
SOURCES += \
|
||||||
mac.cpp \
|
mac.cpp \
|
||||||
|
@ -19,6 +19,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>
|
|||||||
|
|
||||||
#include "updater.h"
|
#include "updater.h"
|
||||||
|
|
||||||
|
#include <QCoreApplication>
|
||||||
#include <QHttp>
|
#include <QHttp>
|
||||||
#include <QTemporaryFile>
|
#include <QTemporaryFile>
|
||||||
#include <QXmlStreamReader>
|
#include <QXmlStreamReader>
|
||||||
@ -47,9 +48,14 @@ Updater::~Updater()
|
|||||||
|
|
||||||
void Updater::checkForNewVersion()
|
void Updater::checkForNewVersion()
|
||||||
{
|
{
|
||||||
http_ = new QHttp("update.ostinato.org");
|
QString host("update.ostinato.org");
|
||||||
|
QHttpRequestHeader reqHdr("GET", "/update/pad.xml");
|
||||||
|
http_ = new QHttp(host);
|
||||||
file_ = new QTemporaryFile();
|
file_ = new QTemporaryFile();
|
||||||
|
|
||||||
|
reqHdr.setValue("Host", host);
|
||||||
|
reqHdr.setValue("UserAgent", userAgent());
|
||||||
|
|
||||||
connect(http_, SIGNAL(responseHeaderReceived(QHttpResponseHeader)),
|
connect(http_, SIGNAL(responseHeaderReceived(QHttpResponseHeader)),
|
||||||
this, SLOT(responseReceived(QHttpResponseHeader)));
|
this, SLOT(responseReceived(QHttpResponseHeader)));
|
||||||
connect(http_, SIGNAL(requestFinished(int, bool)),
|
connect(http_, SIGNAL(requestFinished(int, bool)),
|
||||||
@ -60,7 +66,7 @@ void Updater::checkForNewVersion()
|
|||||||
file_->open();
|
file_->open();
|
||||||
qDebug("Updater: PAD XML file - %s", qPrintable(file_->fileName()));
|
qDebug("Updater: PAD XML file - %s", qPrintable(file_->fileName()));
|
||||||
|
|
||||||
http_->get("/update/pad.xml", file_);
|
http_->request(reqHdr, NULL, file_);
|
||||||
qDebug("Updater: %s", qPrintable(http_->currentRequest().toString()
|
qDebug("Updater: %s", qPrintable(http_->currentRequest().toString()
|
||||||
.replace("\r\n", "\nUpdater: ")));
|
.replace("\r\n", "\nUpdater: ")));
|
||||||
}
|
}
|
||||||
@ -124,4 +130,30 @@ bool Updater::isVersionNewer(QString newVersion, QString curVersion)
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QString Updater::userAgent()
|
||||||
|
{
|
||||||
|
QString ua = QString("Mozilla/5.0 (%1) %2/%3 (Qt/%6)")
|
||||||
|
.arg(sysInfo())
|
||||||
|
.arg(QCoreApplication::instance()->applicationName())
|
||||||
|
.arg(version)
|
||||||
|
.arg(qVersion());
|
||||||
|
|
||||||
|
return ua;
|
||||||
|
}
|
||||||
|
|
||||||
|
QString Updater::sysInfo()
|
||||||
|
{
|
||||||
|
#if defined(Q_OS_WIN32)
|
||||||
|
return QString("Windows/0x%1").arg(QSysInfo::WindowsVersion, 0, 16);
|
||||||
|
#elif defined(Q_OS_LINUX)
|
||||||
|
return QString("Linux");
|
||||||
|
#elif defined(Q_OS_MAC)
|
||||||
|
return QString("MacOSX/0x%1").arg(QSysInfo::MacintoshVersion, 0, 16);
|
||||||
|
#elif defined(Q_OS_BSD4)
|
||||||
|
return QString("BSD");
|
||||||
|
#elif defined(Q_OS_UNIX)
|
||||||
|
return QString("Unix");
|
||||||
|
#else
|
||||||
|
return QString("Unknown");
|
||||||
|
#endif
|
||||||
|
}
|
@ -44,6 +44,9 @@ private slots:
|
|||||||
void parseXml(int id, bool error);
|
void parseXml(int id, bool error);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
QString userAgent();
|
||||||
|
QString sysInfo();
|
||||||
|
|
||||||
QHttp *http_;
|
QHttp *http_;
|
||||||
QTemporaryFile *file_;
|
QTemporaryFile *file_;
|
||||||
};
|
};
|
Loading…
Reference in New Issue
Block a user