Cloud storage: use preference member instead of hard coded strings

This creates the basis to allow other backends to be used with the cloud
storage infrastructure.

So far this should all just transparently continue to work. A user would
have to manually add the cloud_base_url entry to the CloudStorage section
in their config file in order to use a different backend server.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
Dirk Hohndel 2015-06-15 06:05:00 -07:00
parent 617b105458
commit c593dea119
6 changed files with 12 additions and 13 deletions

View file

@ -946,9 +946,9 @@ CloudStorageAuthenticate::CloudStorageAuthenticate(QObject *parent) : QObject(pa
userAgent = getUserAgent();
}
#define CLOUDURL "https://cloud.subsurface-divelog.org/"
#define CLOUDBACKENDSTORAGE CLOUDURL "storage"
#define CLOUDBACKENDVERIFY CLOUDURL "verify"
#define CLOUDURL QString(prefs.cloud_base_url)
#define CLOUDBACKENDSTORAGE CLOUDURL + "/storage"
#define CLOUDBACKENDVERIFY CLOUDURL + "/verify"
QNetworkReply* CloudStorageAuthenticate::authenticate(QString email, QString password, QString pin)
{
@ -1013,7 +1013,7 @@ CheckCloudConnection::CheckCloudConnection(QObject *parent)
}
#define TEAPOT "https://cloud.subsurface-divelog.org/make-latte?number-of-shots=3"
#define TEAPOT "/make-latte?number-of-shots=3"
#define HTTP_I_AM_A_TEAPOT 418
#define MILK "Linus does not like non-fat milk"
bool CheckCloudConnection::checkServer()
@ -1024,7 +1024,7 @@ bool CheckCloudConnection::checkServer()
QNetworkRequest request;
request.setRawHeader("Accept", "text/plain");
request.setRawHeader("User-Agent", getUserAgent().toUtf8());
request.setUrl(QString(TEAPOT));
request.setUrl(QString(prefs.cloud_base_url) + TEAPOT);
QNetworkAccessManager *mgr = new QNetworkAccessManager();
QNetworkReply *reply = mgr->get(request);
connect(&timer, SIGNAL(timeout()), &loop, SLOT(quit()));