From df255e257316c277c51fb5fab5ca5168f0cae631 Mon Sep 17 00:00:00 2001 From: Dirk Hohndel Date: Sat, 13 Jun 2015 09:08:39 -0700 Subject: [PATCH] Don't show an error if you fail to open the cloud storage The lower level functions will already report that things didn't connect successfully, no reason to repeat it here (which then exposes the git URL). Signed-off-by: Dirk Hohndel --- file.c | 6 ++++-- qthelper.cpp | 10 ++++++++++ qthelperfromc.h | 1 + 3 files changed, 15 insertions(+), 2 deletions(-) diff --git a/file.c b/file.c index aae4179cf..bbb396169 100644 --- a/file.c +++ b/file.c @@ -11,6 +11,7 @@ #include "dive.h" #include "file.h" #include "git-access.h" +#include "qthelperfromc.h" /* For SAMPLE_* */ #include @@ -431,8 +432,9 @@ int parse_file(const char *filename) return 0; if (readfile(filename, &mem) < 0) { - /* we don't want to display an error if this was the default file */ - if (prefs.default_filename && !strcmp(filename, prefs.default_filename)) + /* we don't want to display an error if this was the default file or the cloud storage */ + if ((prefs.default_filename && !strcmp(filename, prefs.default_filename)) || + isCloudUrl(filename)) return 0; return report_error(translate("gettextFromC", "Failed to read '%s'"), filename); diff --git a/qthelper.cpp b/qthelper.cpp index 5434bcd20..12ce2cb3c 100644 --- a/qthelper.cpp +++ b/qthelper.cpp @@ -1038,6 +1038,16 @@ int getCloudURL(QString &filename) return 0; } +extern "C" bool isCloudUrl(const char *filename) +{ + QString email = QString(prefs.cloud_storage_email); + email.replace(QRegularExpression("[^a-zA-Z0-9@._+-]"), ""); + if (!email.isEmpty() && + QString("https://cloud.subsurface-divelog.org/git/%1[%1]").arg(email) == filename) + return true; + return false; +} + extern "C" bool getProxyString(char **buffer) { if (prefs.proxy_type == QNetworkProxy::HttpProxy) { diff --git a/qthelperfromc.h b/qthelperfromc.h index d7ba6f1b7..900085fa4 100644 --- a/qthelperfromc.h +++ b/qthelperfromc.h @@ -4,5 +4,6 @@ bool getProxyString(char **buffer); bool canReachCloudServer(); void updateWindowTitle(); +bool isCloudUrl(const char *filename); #endif // QTHELPERFROMC_H