mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
Allow the user to give longer cloud timeout on the command line
When stuck in areas with really bad internet 5 seconds may not be enough, but making the timeout longer in general seems the wrong way to go. So keep the default 5 seconds but allow the user to override that with subsurface --cloud-timeout=NN Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
parent
9815eaf1ed
commit
177e21076b
3 changed files with 13 additions and 4 deletions
|
@ -39,8 +39,8 @@ bool CheckCloudConnection::checkServer()
|
||||||
connect(&timer, &QTimer::timeout, &loop, &QEventLoop::quit);
|
connect(&timer, &QTimer::timeout, &loop, &QEventLoop::quit);
|
||||||
connect(reply, &QNetworkReply::finished, &loop, &QEventLoop::quit);
|
connect(reply, &QNetworkReply::finished, &loop, &QEventLoop::quit);
|
||||||
connect(reply, &QNetworkReply::sslErrors, this, &CheckCloudConnection::sslErrors);
|
connect(reply, &QNetworkReply::sslErrors, this, &CheckCloudConnection::sslErrors);
|
||||||
for (int seconds = 1; seconds <= 5; seconds++) {
|
for (int seconds = 1; seconds <= prefs.cloud_timeout; seconds++) {
|
||||||
timer.start(1000); // wait five seconds
|
timer.start(1000); // wait the given number of seconds (default 5)
|
||||||
loop.exec();
|
loop.exec();
|
||||||
if (timer.isActive()) {
|
if (timer.isActive()) {
|
||||||
// didn't time out, did we get the right response?
|
// didn't time out, did we get the right response?
|
||||||
|
@ -54,7 +54,7 @@ bool CheckCloudConnection::checkServer()
|
||||||
git_storage_update_progress(false, "successfully checked cloud connection");
|
git_storage_update_progress(false, "successfully checked cloud connection");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
} else if (seconds < 5) {
|
} else if (seconds < prefs.cloud_timeout) {
|
||||||
QString text = QString("waited %1 sec for cloud connetion").arg(seconds);
|
QString text = QString("waited %1 sec for cloud connetion").arg(seconds);
|
||||||
git_storage_update_progress(false, qPrintable(text));
|
git_storage_update_progress(false, qPrintable(text));
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -132,6 +132,7 @@ struct preferences {
|
||||||
int time_threshold;
|
int time_threshold;
|
||||||
int distance_threshold;
|
int distance_threshold;
|
||||||
bool git_local_only;
|
bool git_local_only;
|
||||||
|
short cloud_timeout;
|
||||||
locale_prefs_t locale; //: TODO: move the rest of locale based info here.
|
locale_prefs_t locale; //: TODO: move the rest of locale based info here.
|
||||||
};
|
};
|
||||||
enum unit_system_values {
|
enum unit_system_values {
|
||||||
|
|
|
@ -86,7 +86,8 @@ struct preferences default_prefs = {
|
||||||
.deco_mode = BUEHLMANN,
|
.deco_mode = BUEHLMANN,
|
||||||
.conservatism_level = 3,
|
.conservatism_level = 3,
|
||||||
.distance_threshold = 1000,
|
.distance_threshold = 1000,
|
||||||
.time_threshold = 600
|
.time_threshold = 600,
|
||||||
|
.cloud_timeout = 5
|
||||||
};
|
};
|
||||||
|
|
||||||
int run_survey;
|
int run_survey;
|
||||||
|
@ -206,6 +207,13 @@ void parse_argument(const char *arg)
|
||||||
settings_suffix = strdup(arg + sizeof("--user=") - 1);
|
settings_suffix = strdup(arg + sizeof("--user=") - 1);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
if (strncmp(arg, "--cloud-timeout=", sizeof("--cloud-timeout=") - 1) == 0) {
|
||||||
|
const char *timeout = arg + sizeof("--cloud-timeout=") - 1;
|
||||||
|
int to = strtol(timeout, NULL, 10);
|
||||||
|
if (0 < to && to < 60)
|
||||||
|
default_prefs.cloud_timeout = to;
|
||||||
|
return;
|
||||||
|
}
|
||||||
if (strcmp(arg, "--help") == 0) {
|
if (strcmp(arg, "--help") == 0) {
|
||||||
print_help();
|
print_help();
|
||||||
exit(0);
|
exit(0);
|
||||||
|
|
Loading…
Add table
Reference in a new issue