-
-
Notifications
You must be signed in to change notification settings - Fork 25
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
1 parent
dc3c737
commit 45326c2
Showing
13 changed files
with
240 additions
and
8 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 |
---|---|---|
@@ -1,10 +1,17 @@ | ||
0.2.0 (Unreleased) | ||
================== | ||
|
||
- [#6](https://github.com/AlexandrePTJ/kemai/issues/6) Handle user timezone correctly | ||
- [#3](https://github.com/AlexandrePTJ/kemai/issues/3) Add updater | ||
|
||
|
||
0.1.1 (2020-05-09) | ||
================== | ||
|
||
- #2 Fix minimal OSX version | ||
- [#2](https://github.com/AlexandrePTJ/kemai/issues/2) Fix minimal OSX version | ||
|
||
|
||
0.1.0 (2020-05-04) | ||
================== | ||
|
||
Initial version | ||
Initial version |
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 |
---|---|---|
|
@@ -5,4 +5,5 @@ set(CMAKE_AUTORCC ON) | |
|
||
# | ||
add_subdirectory(client) | ||
add_subdirectory(updater) | ||
add_subdirectory(app) |
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
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 |
---|---|---|
@@ -1,3 +1,3 @@ | ||
#pragma once | ||
|
||
#define KEMAI_VERSION "@Kemai_VERSION@" | ||
#define KEMAI_VERSION "@KemaiProject_VERSION@" |
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
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
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
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
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
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 @@ | ||
project(KemaiUpdater) | ||
|
||
find_package(Qt5 COMPONENTS Network CONFIG REQUIRED) | ||
|
||
add_library(${PROJECT_NAME}) | ||
|
||
set(SRCS | ||
kemaiupdater.cpp) | ||
|
||
set(PUB_HDRS | ||
include/kemai/kemaiupdater.h) | ||
|
||
set(PRIV_HDRS | ||
kemaiupdater_p.h) | ||
|
||
target_sources(${PROJECT_NAME} PRIVATE ${SRCS} ${PRIV_HDRS} ${PUB_HDRS}) | ||
target_include_directories(${PROJECT_NAME} PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/include) | ||
target_link_libraries(${PROJECT_NAME} Qt5::Network) |
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,35 @@ | ||
#pragma once | ||
|
||
#include <QObject> | ||
#include <QUrl> | ||
#include <QVersionNumber> | ||
|
||
namespace kemai::updater { | ||
|
||
struct VersionDetails | ||
{ | ||
QVersionNumber vn; | ||
QString description; | ||
QUrl url; | ||
}; | ||
|
||
class KemaiUpdater : public QObject | ||
{ | ||
Q_OBJECT | ||
|
||
public: | ||
explicit KemaiUpdater(QObject* parent = nullptr); | ||
virtual ~KemaiUpdater(); | ||
|
||
void checkAvailableNewVersion(const QVersionNumber& sinceVersion = QVersionNumber(0, 0, 0), | ||
bool silenceIfNoNew = false); | ||
|
||
signals: | ||
void checkFinished(const VersionDetails& kv); | ||
|
||
private: | ||
class KemaiUpdaterPrivate; | ||
QScopedPointer<KemaiUpdaterPrivate> mD; | ||
}; | ||
|
||
} // namespace kemai::updater |
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 "kemai/kemaiupdater.h" | ||
#include "kemaiupdater_p.h" | ||
|
||
#include <QJsonObject> | ||
#include <QJsonDocument> | ||
|
||
using namespace kemai::updater; | ||
|
||
/* | ||
* Private impl | ||
*/ | ||
KemaiUpdater::KemaiUpdaterPrivate::KemaiUpdaterPrivate(KemaiUpdater* c) | ||
: networkAccessManager(new QNetworkAccessManager), mQ(c) | ||
{ | ||
connect(networkAccessManager.data(), &QNetworkAccessManager::finished, this, &KemaiUpdaterPrivate::onNamFinished); | ||
} | ||
|
||
QNetworkRequest KemaiUpdater::KemaiUpdaterPrivate::prepareGithubRequest(const QString& path) | ||
{ | ||
QUrl url; | ||
url.setScheme("https"); | ||
url.setHost("api.github.com"); | ||
url.setPath(path); | ||
|
||
QNetworkRequest r; | ||
r.setUrl(url); | ||
r.setRawHeader("accept", "application/vnd.github.v3+json"); | ||
return r; | ||
} | ||
|
||
void KemaiUpdater::KemaiUpdaterPrivate::onNamFinished(QNetworkReply* reply) | ||
{ | ||
if (reply->error() != QNetworkReply::NoError) | ||
{ | ||
qDebug() << "Error on update check:" << reply->errorString(); | ||
} | ||
else | ||
{ | ||
// Parse json | ||
auto jdoc = QJsonDocument::fromJson(reply->readAll()); | ||
auto jobj = jdoc.object(); | ||
|
||
auto newVersion = QVersionNumber::fromString(jobj.value("tag_name").toString()); | ||
if (newVersion > currentChecksinceVersion) | ||
{ | ||
VersionDetails vd; | ||
vd.vn = newVersion; | ||
vd.description = jobj.value("body").toString(); | ||
vd.url = jobj.value("html_url").toString(); | ||
|
||
emit mQ->checkFinished(vd); | ||
} | ||
else if (not silenceIfNoNew) | ||
{ | ||
emit mQ->checkFinished(VersionDetails()); | ||
} | ||
} | ||
} | ||
|
||
/* | ||
* Public impl | ||
*/ | ||
KemaiUpdater::KemaiUpdater(QObject* parent) : QObject(parent), mD(new KemaiUpdaterPrivate(this)) {} | ||
|
||
KemaiUpdater::~KemaiUpdater() {} | ||
|
||
void KemaiUpdater::checkAvailableNewVersion(const QVersionNumber& sinceVersion, bool silenceIfNoNew) | ||
{ | ||
mD->currentChecksinceVersion = sinceVersion; | ||
mD->silenceIfNoNew = silenceIfNoNew; | ||
|
||
auto rq = mD->prepareGithubRequest("/repos/AlexandrePTJ/kemai/releases/latest"); | ||
mD->networkAccessManager->get(rq); | ||
} |
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 @@ | ||
#pragma once | ||
|
||
//#include <QMap> | ||
#include <QNetworkAccessManager> | ||
#include <QNetworkReply> | ||
#include <QObject> | ||
|
||
#include "kemai/kemaiupdater.h" | ||
|
||
namespace kemai::updater { | ||
|
||
class KemaiUpdater::KemaiUpdaterPrivate : public QObject | ||
{ | ||
Q_OBJECT | ||
|
||
public: | ||
explicit KemaiUpdaterPrivate(KemaiUpdater* c); | ||
|
||
QNetworkRequest prepareGithubRequest(const QString& path); | ||
|
||
public: | ||
QVersionNumber currentChecksinceVersion; | ||
bool silenceIfNoNew; | ||
|
||
QScopedPointer<QNetworkAccessManager> networkAccessManager; | ||
|
||
private slots: | ||
void onNamFinished(QNetworkReply* reply); | ||
|
||
private: | ||
KemaiUpdater* const mQ; | ||
}; | ||
|
||
} // namespace kemai::client |