-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 46fe87d
Showing
31 changed files
with
1,688 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
# Mac OS X | ||
.DS_Store | ||
|
||
# C++ | ||
*.o | ||
*.a | ||
*.dylib | ||
|
||
# Qt | ||
*.prl | ||
Makefile | ||
Makefile.* | ||
moc_* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
#ifndef QTXUPDATE_MODULE_H | ||
#define QTXUPDATE_MODULE_H | ||
|
||
#include "../src/update/abstractupdatechecker.h" | ||
#include "../src/update/abstractupdatefilter.h" | ||
#include "../src/update/abstractversioncomparator.h" | ||
#include "../src/update/appcastsysupdatefilter.h" | ||
#include "../src/update/appcastupdatechecker.h" | ||
#include "../src/update/semversortupdatefilter.h" | ||
#include "../src/update/semverversioncomparator.h" | ||
#include "../src/update/update.h" | ||
#include "../src/update/updatedialog.h" | ||
#include "../src/update/updateresolver.h" | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
include(src/update/update.pri) | ||
|
||
INCLUDEPATH += $$PWD/include |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
#include "abstractupdatechecker.h" | ||
|
||
|
||
AbstractUpdateChecker::AbstractUpdateChecker(QObject *parent /* = 0 */) | ||
: QObject(parent) | ||
{ | ||
} | ||
|
||
AbstractUpdateChecker::~AbstractUpdateChecker() | ||
{ | ||
} | ||
|
||
QString AbstractUpdateChecker::errorString() const | ||
{ | ||
return mErrorString; | ||
} | ||
|
||
void AbstractUpdateChecker::setErrorString(const QString & str) | ||
{ | ||
mErrorString = str; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
#ifndef ABSTRACTUPDATECHECKER_H | ||
#define ABSTRACTUPDATECHECKER_H | ||
|
||
#include <QtCore> | ||
|
||
|
||
class Update; | ||
|
||
class AbstractUpdateChecker : public QObject | ||
{ | ||
Q_OBJECT | ||
|
||
public: | ||
AbstractUpdateChecker(QObject *parent = 0); | ||
virtual ~AbstractUpdateChecker(); | ||
|
||
virtual void check() = 0; | ||
|
||
virtual QList<Update *> updates() = 0; | ||
|
||
QString errorString() const; | ||
|
||
signals: | ||
void finished(); | ||
void error(qint32 code); | ||
|
||
protected: | ||
void setErrorString(const QString & str); | ||
|
||
private: | ||
QString mErrorString; | ||
}; | ||
|
||
#endif // ABSTRACTUPDATECHECKER_H |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
#include "abstractupdatefilter.h" | ||
|
||
|
||
AbstractUpdateFilter::AbstractUpdateFilter(QObject *parent /* = 0 */) | ||
: QObject(parent) | ||
{ | ||
} | ||
|
||
AbstractUpdateFilter::~AbstractUpdateFilter() | ||
{ | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
#ifndef ABSTRACTUPDATEFILTER_H | ||
#define ABSTRACTUPDATEFILTER_H | ||
|
||
#include <QtCore> | ||
|
||
|
||
class Update; | ||
|
||
class AbstractUpdateFilter : public QObject | ||
{ | ||
Q_OBJECT | ||
|
||
public: | ||
AbstractUpdateFilter(QObject *parent = 0); | ||
virtual ~AbstractUpdateFilter(); | ||
|
||
virtual QList<Update *> filter(const QList<Update *> candidates) = 0; | ||
}; | ||
|
||
#endif // ABSTRACTUPDATEFILTER_H |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
#include "abstractversioncomparator.h" | ||
|
||
|
||
AbstractVersionComparator::AbstractVersionComparator(QObject *parent /* = 0 */) | ||
: QObject(parent) | ||
{ | ||
} | ||
|
||
AbstractVersionComparator::~AbstractVersionComparator() | ||
{ | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
#ifndef ABSTRACTVERSIONCOMPARATOR_H | ||
#define ABSTRACTVERSIONCOMPARATOR_H | ||
|
||
#include <QtCore> | ||
|
||
|
||
class AbstractVersionComparator : public QObject | ||
{ | ||
Q_OBJECT | ||
|
||
public: | ||
AbstractVersionComparator(QObject *parent = 0); | ||
virtual ~AbstractVersionComparator(); | ||
|
||
virtual int compare(const QString & lhs, const QString & rhs) = 0; | ||
}; | ||
|
||
#endif // ABSTRACTVERSIONCOMPARATOR_H |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
#include "appcastenclosure.h" | ||
#include "appcastitem.h" | ||
|
||
|
||
const char AppcastEnclosure::kXmlElementName[] = "enclosure"; | ||
const char AppcastEnclosure::kVersionXmlElementName[] = "version"; | ||
const char AppcastEnclosure::kUrlXmlElementName[] = "url"; | ||
const char AppcastEnclosure::kTypeXmlElementName[] = "type"; | ||
|
||
AppcastEnclosure::AppcastEnclosure(QObject *parent /* = 0 */) | ||
: QObject(parent), | ||
mDepth(0) | ||
{ | ||
} | ||
|
||
AppcastEnclosure::~AppcastEnclosure() | ||
{ | ||
} | ||
|
||
QString AppcastEnclosure::version() const | ||
{ | ||
return mVersion; | ||
} | ||
|
||
QUrl AppcastEnclosure::url() const | ||
{ | ||
return mUrl; | ||
} | ||
|
||
QString AppcastEnclosure::mimeType() const | ||
{ | ||
return mMimeType; | ||
} | ||
|
||
IXmlDeserializer* AppcastEnclosure::deserializeXmlStartElement(XmlReader* reader, const QStringRef & namespaceUri, const QStringRef & name, const QXmlStreamAttributes & attributes) | ||
{ | ||
Q_UNUSED(reader) | ||
Q_UNUSED(namespaceUri) | ||
Q_UNUSED(name) | ||
Q_UNUSED(attributes) | ||
|
||
mDepth++; | ||
return this; | ||
} | ||
|
||
void AppcastEnclosure::deserializeXmlEndElement(XmlReader* reader, const QStringRef & namespaceUri, const QStringRef & name) | ||
{ | ||
Q_UNUSED(reader) | ||
Q_UNUSED(namespaceUri) | ||
Q_UNUSED(name) | ||
|
||
if (!mDepth) { | ||
emit parsed(); | ||
return; | ||
} | ||
|
||
mDepth--; | ||
} | ||
|
||
void AppcastEnclosure::deserializeXmlAttributes(XmlReader* reader, const QXmlStreamAttributes & attributes) | ||
{ | ||
Q_UNUSED(reader) | ||
Q_UNUSED(attributes) | ||
|
||
mVersion = attributes.value(AppcastItem::kSparkleXmlNamespace, kVersionXmlElementName).toString(); | ||
mUrl = QUrl(attributes.value("", kUrlXmlElementName).toString()); | ||
mMimeType = attributes.value("", kTypeXmlElementName).toString(); | ||
} | ||
|
||
void AppcastEnclosure::deserializeXmlCharacters(XmlReader* reader, const QStringRef & text) | ||
{ | ||
Q_UNUSED(reader) | ||
Q_UNUSED(text) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
#ifndef APPCASTENCLOSURE_H | ||
#define APPCASTENCLOSURE_H | ||
|
||
#include <QtCore> | ||
#include "../../../src/xml/xml.h" | ||
|
||
|
||
class AppcastEnclosure : public QObject, | ||
public IXmlDeserializer | ||
{ | ||
Q_OBJECT | ||
|
||
public: | ||
AppcastEnclosure(QObject *parent = 0); | ||
virtual ~AppcastEnclosure(); | ||
|
||
QString version() const; | ||
QUrl url() const; | ||
QString mimeType() const; | ||
|
||
signals: | ||
void parsed(); | ||
|
||
private: | ||
IXmlDeserializer* deserializeXmlStartElement(XmlReader* reader, const QStringRef & namespaceUri, const QStringRef & name, const QXmlStreamAttributes & attributes); | ||
void deserializeXmlEndElement(XmlReader* reader, const QStringRef & namespaceUri, const QStringRef & name); | ||
void deserializeXmlAttributes(XmlReader* reader, const QXmlStreamAttributes & attributes); | ||
void deserializeXmlCharacters(XmlReader* reader, const QStringRef & text); | ||
|
||
private: | ||
QString mVersion; | ||
QUrl mUrl; | ||
QString mMimeType; | ||
|
||
quint32 mDepth; | ||
|
||
public: | ||
static const char kXmlElementName[]; | ||
private: | ||
static const char kVersionXmlElementName[]; | ||
static const char kUrlXmlElementName[]; | ||
static const char kTypeXmlElementName[]; | ||
}; | ||
|
||
#endif // APPCASTENCLOSURE_H |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,119 @@ | ||
#include "appcastitem.h" | ||
#include "appcastenclosure.h" | ||
|
||
|
||
const char AppcastItem::kSparkleXmlNamespace[] = "http://www.andymatuschak.org/xml-namespaces/sparkle"; | ||
const char AppcastItem::kXmlElementName[] = "item"; | ||
const char AppcastItem::kTitleXmlElementName[] = "title"; | ||
const char AppcastItem::kLinkXmlElementName[] = "link"; | ||
const char AppcastItem::kMinimumSystemVersionXmlElementName[] = "minimumSystemVersion"; | ||
|
||
AppcastItem::AppcastItem(QObject *parent /* = 0 */) | ||
: QObject(parent), | ||
mParsingEnclosure(0), | ||
mDepth(0) | ||
{ | ||
} | ||
|
||
AppcastItem::~AppcastItem() | ||
{ | ||
} | ||
|
||
QString AppcastItem::title() const | ||
{ | ||
return mTitle; | ||
} | ||
|
||
QString AppcastItem::version() const | ||
{ | ||
return mVersion; | ||
} | ||
|
||
QUrl AppcastItem::linkUrl() const | ||
{ | ||
return mLinkUrl; | ||
} | ||
|
||
const AppcastEnclosure *AppcastItem::enclosure() const | ||
{ | ||
if (mEnclosures.isEmpty()) { | ||
return 0; | ||
} | ||
|
||
return mEnclosures.at(0); | ||
} | ||
|
||
QString AppcastItem::minSystemVersion() const | ||
{ | ||
return mMinSystemVersion; | ||
} | ||
|
||
void AppcastItem::onEnclosureParsed() | ||
{ | ||
mParsingEnclosure->disconnect(this); | ||
|
||
mEnclosures.append(mParsingEnclosure); | ||
if (mEnclosures.size() == 1) { | ||
// Sparkle's RSS extension is rather poorly specified. The version is | ||
// logically associated with the item, but is indicated as an attribute | ||
// of the enclosure (of which there can be many, in the case of | ||
// per-platform enclosures). The version of the first enclosure will be | ||
// treated as the item's version. For consistency, it is recommended | ||
// that any item containing multiple enclosures indicates an identical | ||
// version for each. | ||
mVersion = mParsingEnclosure->version(); | ||
} | ||
|
||
mParsingEnclosure = 0; | ||
} | ||
|
||
IXmlDeserializer* AppcastItem::deserializeXmlStartElement(XmlReader* reader, const QStringRef & namespaceUri, const QStringRef & name, const QXmlStreamAttributes & attributes) | ||
{ | ||
Q_UNUSED(reader) | ||
Q_UNUSED(namespaceUri) | ||
Q_UNUSED(name) | ||
Q_UNUSED(attributes) | ||
|
||
if (AppcastEnclosure::kXmlElementName == name) { | ||
mParsingEnclosure = new AppcastEnclosure(this); | ||
connect(mParsingEnclosure, SIGNAL(parsed()), SLOT(onEnclosureParsed())); | ||
return mParsingEnclosure; | ||
} | ||
|
||
mDepth++; | ||
return this; | ||
} | ||
|
||
void AppcastItem::deserializeXmlEndElement(XmlReader* reader, const QStringRef & namespaceUri, const QStringRef & name) | ||
{ | ||
Q_UNUSED(reader) | ||
|
||
if (!mDepth) { | ||
emit parsed(); | ||
return; | ||
} | ||
|
||
if (kTitleXmlElementName == name) { | ||
mTitle = mCharacters.trimmed(); | ||
} else if (kLinkXmlElementName == name) { | ||
mLinkUrl = QUrl(mCharacters.trimmed()); | ||
} else if (namespaceUri == kSparkleXmlNamespace && kMinimumSystemVersionXmlElementName == name) { | ||
mMinSystemVersion = mCharacters.trimmed(); | ||
} | ||
|
||
mDepth--; | ||
mCharacters.clear(); | ||
} | ||
|
||
void AppcastItem::deserializeXmlAttributes(XmlReader* reader, const QXmlStreamAttributes & attributes) | ||
{ | ||
Q_UNUSED(reader) | ||
Q_UNUSED(attributes) | ||
} | ||
|
||
void AppcastItem::deserializeXmlCharacters(XmlReader* reader, const QStringRef & text) | ||
{ | ||
Q_UNUSED(reader) | ||
|
||
mCharacters.append(text); | ||
} |
Oops, something went wrong.