summaryrefslogtreecommitdiff
path: root/app/pebblestoreview.cpp
diff options
context:
space:
mode:
authorTomasz Sterna <tomek@xiaoka.com>2015-10-11 00:34:46 +0200
committerTomasz Sterna <tomek@xiaoka.com>2015-10-11 00:34:46 +0200
commitdae309fe62dd97ade9d1ec84fdffe4eab44fb623 (patch)
tree1ed80ecede0876ed7b5e1f85cac5914b24abeecf /app/pebblestoreview.cpp
parentdff2ba6143d68515f884753e9cc81cdf7ed0eca1 (diff)
parent8bee022b0ff7659cb5b0bd35febae09826d8d298 (diff)
Merge pull request #94 from smurfy/fix-79
Added support for pebble-time appstore fixes #79
Diffstat (limited to 'app/pebblestoreview.cpp')
-rw-r--r--app/pebblestoreview.cpp38
1 files changed, 33 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()<<this->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()<<baseUrl;