Cloud storage: Setup http proxy for git connection

At the time of this commit support for this feature has not landed in
upstream libgit2, yet (but there is a pull request). Yet supporting this
here doesn't appear to cause any issue with older versions of libgit2,
either, so the http proxy support will simply not work when enabled and a
version of libgit2 that's too old is used.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
Dirk Hohndel 2015-06-12 06:24:48 -07:00
parent 3ff3577eda
commit 490d21806e
2 changed files with 33 additions and 6 deletions

View file

@ -24,6 +24,7 @@
#include <QNetworkReply>
#include <QNetworkRequest>
#include <QNetworkAccessManager>
#include <QNetworkProxy>
#include <QUrlQuery>
#include <QEventLoop>
#include <QDateTime>
@ -1034,3 +1035,19 @@ int getCloudURL(QString &filename)
filename = QString("https://cloud.subsurface-divelog.org/git/%1[%1]").arg(email);
return 0;
}
extern "C" bool getProxyString(char **buffer)
{
if (prefs.proxy_type == QNetworkProxy::HttpProxy) {
QString proxy;
if (prefs.proxy_auth)
proxy = QString("http://%1:%2@%3:%4").arg(prefs.proxy_user).arg(prefs.proxy_pass)
.arg(prefs.proxy_host).arg(prefs.proxy_port);
else
proxy = QString("http://%1:%2").arg(prefs.proxy_host).arg(prefs.proxy_port);
if (buffer)
*buffer = strdup(qPrintable(proxy));
return true;
}
return false;
}