From 8bee022b0ff7659cb5b0bd35febae09826d8d298 Mon Sep 17 00:00:00 2001 From: Philipp Andreas Date: Sat, 10 Oct 2015 20:01:37 +0200 Subject: Added support for pebble-time appstore fixes #79 --- app/pebblestoreview.cpp | 38 +++++++++++++++++++++++++++++++++----- app/pebblestoreview.h | 6 ++++++ app/qml/pages/AppStorePage.qml | 1 + daemon/watchconnector.cpp | 13 +++++++++++++ daemon/watchconnector.h | 1 + 5 files changed, 54 insertions(+), 5 deletions(-) diff --git a/app/pebblestoreview.cpp b/app/pebblestoreview.cpp index 717eff3..17d690f 100644 --- a/app/pebblestoreview.cpp +++ b/app/pebblestoreview.cpp @@ -11,8 +11,18 @@ PebbleStoreView::PebbleStoreView() this->m_networkManager = new QNetworkAccessManager(this); connect(this->m_networkManager, SIGNAL(finished(QNetworkReply*)), this, SLOT(onNetworkReplyFinished(QNetworkReply*))); +} + +void PebbleStoreView::fetchConfig() +{ + qDebug()<m_hardwarePlatform; + + if (this->m_hardwarePlatform == "aplite") { + this->m_configUrl = QUrl("https://boot.getpebble.com/api/config/android/v1/3"); + } else { + this->m_configUrl = QUrl("https://boot.getpebble.com/api/config/android/v3/1?app_version=3.4.0"); + } - this->m_configUrl = QUrl("https://boot.getpebble.com/api/config/android/v1/3"); this->m_downloadInProgress = false; emit downloadInProgressChanged(); @@ -31,10 +41,25 @@ void PebbleStoreView::setAccessToken(const QString &accessToken) emit accessTokenChanged(accessToken); } +QString PebbleStoreView::hardwarePlatform() const +{ + return this->m_hardwarePlatform; +} + +void PebbleStoreView::setHardwarePlatform(const QString &hardwarePlatform) +{ + this->m_hardwarePlatform = hardwarePlatform; + emit hardwarePlatformChanged(hardwarePlatform); + + //We need to refetch the config after a platform change + this->fetchConfig(); +} + + void PebbleStoreView::logout() { setAccessToken(""); - setUrl(prepareUrl(this->storeConfigObject.value("webviews").toObject().value("authentication").toString())); + setUrl(prepareUrl(this->storeConfigObject.value("webviews").toObject().value("authentication/sign_in").toString())); } bool PebbleStoreView::loggedin() @@ -128,7 +153,7 @@ void PebbleStoreView::onNetworkReplyFinished(QNetworkReply* reply) this->storeConfigObject = jsonObject.value("config").toObject(); if (this->m_accessToken.isEmpty()) { - setUrl(prepareUrl(this->storeConfigObject.value("webviews").toObject().value("authentication").toString())); + setUrl(prepareUrl(this->storeConfigObject.value("webviews").toObject().value("authentication/sign_in").toString())); } else { setUrl(prepareUrl(this->storeConfigObject.value("webviews").toObject().value("onboarding/get_some_apps").toString())); } @@ -164,9 +189,12 @@ void PebbleStoreView::onNetworkReplyFinished(QNetworkReply* reply) QUrl PebbleStoreView::prepareUrl(QString baseUrl) { baseUrl = baseUrl.replace("$$user_id$$", "ZZZ"); - baseUrl = baseUrl.replace("$$phone_id$$", "XXX"); - baseUrl = baseUrl.replace("$$pebble_id$$", "YYY"); + baseUrl = baseUrl.replace("$$phone_id$$", "XXX"); //Unique phone id + baseUrl = baseUrl.replace("$$pebble_id$$", "YYY"); //official APP puts serial here + baseUrl = baseUrl.replace("$$pebble_color$$", "64"); + baseUrl = baseUrl.replace("$$hardware$$", this->m_hardwarePlatform); baseUrl = baseUrl.replace("$$access_token$$", this->m_accessToken); + baseUrl = baseUrl.replace("$$extras$$", ""); qDebug()<bootLoaderBuild.toTime_t()); map.insert("serial", this->serialNumber); map.insert("address", this->address.toHex()); + map.insert("platform", this->hardwarePlatform); map.insertMulti("firmware", this->main.toMap()); map.insertMulti("firmware", this->safe.toMap()); } @@ -126,6 +127,18 @@ WatchConnector::WatchConnector(QObject *parent) : platform = hardwareMapping.value(_versions.safe.hw_revision).first; + switch (this->platform) { + case APLITE: + _versions.hardwarePlatform = "aplite"; + break; + case BASALT: + _versions.hardwarePlatform = "basalt"; + break; + case CHALK: + _versions.hardwarePlatform = "chalk"; + break; + } + if (u.bad()) { qCWarning(l) << "short read while reading firmware version"; } else { diff --git a/daemon/watchconnector.h b/daemon/watchconnector.h index 27555a3..83e065c 100644 --- a/daemon/watchconnector.h +++ b/daemon/watchconnector.h @@ -197,6 +197,7 @@ public: SoftwareVersion safe; QDateTime bootLoaderBuild; QString hardwareRevision; + QString hardwarePlatform; QString serialNumber; QByteArray address; -- cgit v1.2.3