Skip to content

Commit 46fe87d

Browse files
committed
Initial commit.
0 parents  commit 46fe87d

31 files changed

+1688
-0
lines changed

.gitignore

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# Mac OS X
2+
.DS_Store
3+
4+
# C++
5+
*.o
6+
*.a
7+
*.dylib
8+
9+
# Qt
10+
*.prl
11+
Makefile
12+
Makefile.*
13+
moc_*

include/QtxUpdate

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
#ifndef QTXUPDATE_MODULE_H
2+
#define QTXUPDATE_MODULE_H
3+
4+
#include "../src/update/abstractupdatechecker.h"
5+
#include "../src/update/abstractupdatefilter.h"
6+
#include "../src/update/abstractversioncomparator.h"
7+
#include "../src/update/appcastsysupdatefilter.h"
8+
#include "../src/update/appcastupdatechecker.h"
9+
#include "../src/update/semversortupdatefilter.h"
10+
#include "../src/update/semverversioncomparator.h"
11+
#include "../src/update/update.h"
12+
#include "../src/update/updatedialog.h"
13+
#include "../src/update/updateresolver.h"
14+
15+
#endif

qtxupdate.pri

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
include(src/update/update.pri)
2+
3+
INCLUDEPATH += $$PWD/include

src/update/abstractupdatechecker.cpp

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
#include "abstractupdatechecker.h"
2+
3+
4+
AbstractUpdateChecker::AbstractUpdateChecker(QObject *parent /* = 0 */)
5+
: QObject(parent)
6+
{
7+
}
8+
9+
AbstractUpdateChecker::~AbstractUpdateChecker()
10+
{
11+
}
12+
13+
QString AbstractUpdateChecker::errorString() const
14+
{
15+
return mErrorString;
16+
}
17+
18+
void AbstractUpdateChecker::setErrorString(const QString & str)
19+
{
20+
mErrorString = str;
21+
}

src/update/abstractupdatechecker.h

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
#ifndef ABSTRACTUPDATECHECKER_H
2+
#define ABSTRACTUPDATECHECKER_H
3+
4+
#include <QtCore>
5+
6+
7+
class Update;
8+
9+
class AbstractUpdateChecker : public QObject
10+
{
11+
Q_OBJECT
12+
13+
public:
14+
AbstractUpdateChecker(QObject *parent = 0);
15+
virtual ~AbstractUpdateChecker();
16+
17+
virtual void check() = 0;
18+
19+
virtual QList<Update *> updates() = 0;
20+
21+
QString errorString() const;
22+
23+
signals:
24+
void finished();
25+
void error(qint32 code);
26+
27+
protected:
28+
void setErrorString(const QString & str);
29+
30+
private:
31+
QString mErrorString;
32+
};
33+
34+
#endif // ABSTRACTUPDATECHECKER_H

src/update/abstractupdatefilter.cpp

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
#include "abstractupdatefilter.h"
2+
3+
4+
AbstractUpdateFilter::AbstractUpdateFilter(QObject *parent /* = 0 */)
5+
: QObject(parent)
6+
{
7+
}
8+
9+
AbstractUpdateFilter::~AbstractUpdateFilter()
10+
{
11+
}

src/update/abstractupdatefilter.h

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
#ifndef ABSTRACTUPDATEFILTER_H
2+
#define ABSTRACTUPDATEFILTER_H
3+
4+
#include <QtCore>
5+
6+
7+
class Update;
8+
9+
class AbstractUpdateFilter : public QObject
10+
{
11+
Q_OBJECT
12+
13+
public:
14+
AbstractUpdateFilter(QObject *parent = 0);
15+
virtual ~AbstractUpdateFilter();
16+
17+
virtual QList<Update *> filter(const QList<Update *> candidates) = 0;
18+
};
19+
20+
#endif // ABSTRACTUPDATEFILTER_H
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
#include "abstractversioncomparator.h"
2+
3+
4+
AbstractVersionComparator::AbstractVersionComparator(QObject *parent /* = 0 */)
5+
: QObject(parent)
6+
{
7+
}
8+
9+
AbstractVersionComparator::~AbstractVersionComparator()
10+
{
11+
}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
#ifndef ABSTRACTVERSIONCOMPARATOR_H
2+
#define ABSTRACTVERSIONCOMPARATOR_H
3+
4+
#include <QtCore>
5+
6+
7+
class AbstractVersionComparator : public QObject
8+
{
9+
Q_OBJECT
10+
11+
public:
12+
AbstractVersionComparator(QObject *parent = 0);
13+
virtual ~AbstractVersionComparator();
14+
15+
virtual int compare(const QString & lhs, const QString & rhs) = 0;
16+
};
17+
18+
#endif // ABSTRACTVERSIONCOMPARATOR_H

src/update/appcastenclosure.cpp

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
#include "appcastenclosure.h"
2+
#include "appcastitem.h"
3+
4+
5+
const char AppcastEnclosure::kXmlElementName[] = "enclosure";
6+
const char AppcastEnclosure::kVersionXmlElementName[] = "version";
7+
const char AppcastEnclosure::kUrlXmlElementName[] = "url";
8+
const char AppcastEnclosure::kTypeXmlElementName[] = "type";
9+
10+
AppcastEnclosure::AppcastEnclosure(QObject *parent /* = 0 */)
11+
: QObject(parent),
12+
mDepth(0)
13+
{
14+
}
15+
16+
AppcastEnclosure::~AppcastEnclosure()
17+
{
18+
}
19+
20+
QString AppcastEnclosure::version() const
21+
{
22+
return mVersion;
23+
}
24+
25+
QUrl AppcastEnclosure::url() const
26+
{
27+
return mUrl;
28+
}
29+
30+
QString AppcastEnclosure::mimeType() const
31+
{
32+
return mMimeType;
33+
}
34+
35+
IXmlDeserializer* AppcastEnclosure::deserializeXmlStartElement(XmlReader* reader, const QStringRef & namespaceUri, const QStringRef & name, const QXmlStreamAttributes & attributes)
36+
{
37+
Q_UNUSED(reader)
38+
Q_UNUSED(namespaceUri)
39+
Q_UNUSED(name)
40+
Q_UNUSED(attributes)
41+
42+
mDepth++;
43+
return this;
44+
}
45+
46+
void AppcastEnclosure::deserializeXmlEndElement(XmlReader* reader, const QStringRef & namespaceUri, const QStringRef & name)
47+
{
48+
Q_UNUSED(reader)
49+
Q_UNUSED(namespaceUri)
50+
Q_UNUSED(name)
51+
52+
if (!mDepth) {
53+
emit parsed();
54+
return;
55+
}
56+
57+
mDepth--;
58+
}
59+
60+
void AppcastEnclosure::deserializeXmlAttributes(XmlReader* reader, const QXmlStreamAttributes & attributes)
61+
{
62+
Q_UNUSED(reader)
63+
Q_UNUSED(attributes)
64+
65+
mVersion = attributes.value(AppcastItem::kSparkleXmlNamespace, kVersionXmlElementName).toString();
66+
mUrl = QUrl(attributes.value("", kUrlXmlElementName).toString());
67+
mMimeType = attributes.value("", kTypeXmlElementName).toString();
68+
}
69+
70+
void AppcastEnclosure::deserializeXmlCharacters(XmlReader* reader, const QStringRef & text)
71+
{
72+
Q_UNUSED(reader)
73+
Q_UNUSED(text)
74+
}

0 commit comments

Comments
 (0)