aboutsummaryrefslogtreecommitdiffstats
path: root/apps/com.pelagicore.downloads/stores/ServerConfig.qml
diff options
context:
space:
mode:
authorEgor Nemtsev <enemtsev@luxoft.com>2019-06-21 12:34:20 +0300
committerEgor Nemtsev <enemtsev@luxoft.com>2019-06-21 14:29:39 +0000
commit214eaf3c353c7bae0616ac66b3af8cc8fec56aa3 (patch)
treee28aedc926e6bc536045da5249d48d477684d7dd /apps/com.pelagicore.downloads/stores/ServerConfig.qml
parentd6ebc6fce8fc121340dbe4e8665d614ef309afda (diff)
[downloads] fix check deployment server network access
Task-number: AUTOSUITE-1039 Change-Id: I1bc0bf0a9583f3023dd0c680945759e4a1641229 Reviewed-by: Grigorii Zimin <gzimin@luxoft.com>
Diffstat (limited to 'apps/com.pelagicore.downloads/stores/ServerConfig.qml')
-rw-r--r--apps/com.pelagicore.downloads/stores/ServerConfig.qml81
1 files changed, 58 insertions, 23 deletions
diff --git a/apps/com.pelagicore.downloads/stores/ServerConfig.qml b/apps/com.pelagicore.downloads/stores/ServerConfig.qml
index 198f57a0..90224519 100644
--- a/apps/com.pelagicore.downloads/stores/ServerConfig.qml
+++ b/apps/com.pelagicore.downloads/stores/ServerConfig.qml
@@ -46,34 +46,68 @@ QtObject {
property string userName: ApplicationManager.systemProperties.userName
property string userPassword: ApplicationManager.systemProperties.userPassword
readonly property string imei: ApplicationManager.systemProperties.imei
+ property bool isReconnecting: false
signal loginSuccessful()
- function checkServer() {
- console.log(Logging.apps, "Neptune-UI::Application Store - Check Server");
- var url = serverUrl + "/hello";
- var data = {"platform" : "NEPTUNE3", "version" : "1", "architecture": root.cpuArch};
- JSONBackend.setErrorFunction(function () {
- serverOnline = false;
- serverReason = "unknown";
- })
- JSONBackend.serverCall(url, data, function(data) {
- if (data !== 0) {
- if (data.status === "ok") {
- serverOnline = true;
- root.login();
- } else if (data.status === "maintenance") {
- serverOnline = false;
- serverReason = "maintenance";
- } else {
- console.log(Logging.apps, "Server Call Err: " + data.error);
- serverOnline = false;
- }
+ property var d: QtObject {
+
+ property int attempt: 0
+ property Timer retryTimer: Timer {
+ interval: 2000
+ onTriggered: {
+ d.checkServerPrivate()
+ }
+ }
+
+ function retry() {
+ console.log(Logging.apps, "Neptune-UI::Application Store - Retry Connection");
+ if (attempt < 5) {
+ attempt += 1;
+ retryTimer.start();
} else {
- serverOnline = false;
- serverReason = "unknown";
+ root.isReconnecting = false;
}
- })
+ }
+
+ function checkServerPrivate() {
+ root.isReconnecting = true;
+ console.log(Logging.apps, "Neptune-UI::Application Store - Check Server");
+ var url = root.serverUrl + "/hello";
+ var data = {"platform" : "NEPTUNE3", "version" : "1", "architecture": root.cpuArch};
+ JSONBackend.setErrorFunction(function () {
+ root.serverOnline = false;
+ root.serverReason = "unknown";
+ root.d.retry()
+ })
+ JSONBackend.serverCall(url, data, function(data) {
+ if (data !== 0) {
+ if (data.status === "ok") {
+ root.d.attempt = 0
+ root.serverOnline = true;
+ root.isReconnecting = false;
+ root.login();
+ } else if (data.status === "maintenance") {
+ console.log(Logging.apps, "Server Call: maintenance");
+ root.serverOnline = false;
+ root.serverReason = "maintenance";
+ } else {
+ console.log(Logging.apps, "Server Call Err: " + data.error);
+ root.serverOnline = false;
+ root.d.retry()
+ }
+ } else {
+ root.serverOnline = false;
+ root.serverReason = "unknown";
+ root.d.retry();
+ }
+ })
+ }
+ }
+
+ function checkServer() {
+ root.d.attempt = 0
+ root.d.checkServerPrivate()
}
function login() {
@@ -90,6 +124,7 @@ QtObject {
}
})
}
+
Component.onCompleted: root.checkServer();
}