-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathProxyCredentialsHandler.h
More file actions
49 lines (38 loc) · 1.08 KB
/
ProxyCredentialsHandler.h
File metadata and controls
49 lines (38 loc) · 1.08 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
#ifndef PROXYCREDENTIALSHANDLER_H
#define PROXYCREDENTIALSHANDLER_H
#include <QObject>
#include <QNetworkProxy>
#include <QAuthenticator>
//Singleton that determines/caches proxy credentials
class ProxyCredentialsHandler
: public QObject
{
Q_OBJECT
public:
static ProxyCredentialsHandler& instance()
{
static ProxyCredentialsHandler instance;
return instance;
}
//Sets credentialy manually (not necessary in most cases)
void setCredentials(QString host, QString user, QString password)
{
host = host.toLower().trimmed();
credentials_[host] = qMakePair(user, password);
}
//Clears all cached credentials
void clearCredentials()
{
credentials_.clear();
}
//Enable user dialog
void enableUserDialog(bool enabled) { enable_credentials_dialog_ = enabled; }
public slots:
void proxyAuthenticationRequired(const QNetworkProxy& proxy, QAuthenticator* authenticator);
private:
ProxyCredentialsHandler();
Q_DISABLE_COPY_MOVE(ProxyCredentialsHandler)
QHash<QString, QPair<QString, QString>> credentials_;
bool enable_credentials_dialog_;
};
#endif // PROXYCREDENTIALSHANDLER_H