Source code

Revision control

Other Tools

1
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2
/* vim:set ts=2 sw=2 sts=2 et cindent: */
3
/* This Source Code Form is subject to the terms of the Mozilla Public
4
* License, v. 2.0. If a copy of the MPL was not distributed with this
5
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
6
7
#include "nsProxyInfo.h"
8
#include "nsCOMPtr.h"
9
10
namespace mozilla {
11
namespace net {
12
13
// Yes, we support QI to nsProxyInfo
14
NS_IMPL_ISUPPORTS(nsProxyInfo, nsProxyInfo, nsIProxyInfo)
15
16
NS_IMETHODIMP
17
nsProxyInfo::GetHost(nsACString& result) {
18
result = mHost;
19
return NS_OK;
20
}
21
22
NS_IMETHODIMP
23
nsProxyInfo::GetPort(int32_t* result) {
24
*result = mPort;
25
return NS_OK;
26
}
27
28
NS_IMETHODIMP
29
nsProxyInfo::GetType(nsACString& result) {
30
result = mType;
31
return NS_OK;
32
}
33
34
NS_IMETHODIMP
35
nsProxyInfo::GetFlags(uint32_t* result) {
36
*result = mFlags;
37
return NS_OK;
38
}
39
40
NS_IMETHODIMP
41
nsProxyInfo::GetResolveFlags(uint32_t* result) {
42
*result = mResolveFlags;
43
return NS_OK;
44
}
45
46
NS_IMETHODIMP
47
nsProxyInfo::GetUsername(nsACString& result) {
48
result = mUsername;
49
return NS_OK;
50
}
51
52
NS_IMETHODIMP
53
nsProxyInfo::GetPassword(nsACString& result) {
54
result = mPassword;
55
return NS_OK;
56
}
57
58
NS_IMETHODIMP
59
nsProxyInfo::GetProxyAuthorizationHeader(nsACString& result) {
60
result = mProxyAuthorizationHeader;
61
return NS_OK;
62
}
63
64
NS_IMETHODIMP
65
nsProxyInfo::GetConnectionIsolationKey(nsACString& result) {
66
result = mConnectionIsolationKey;
67
return NS_OK;
68
}
69
70
NS_IMETHODIMP
71
nsProxyInfo::GetFailoverTimeout(uint32_t* result) {
72
*result = mTimeout;
73
return NS_OK;
74
}
75
76
NS_IMETHODIMP
77
nsProxyInfo::GetFailoverProxy(nsIProxyInfo** result) {
78
NS_IF_ADDREF(*result = mNext);
79
return NS_OK;
80
}
81
82
NS_IMETHODIMP
83
nsProxyInfo::SetFailoverProxy(nsIProxyInfo* proxy) {
84
nsCOMPtr<nsProxyInfo> pi = do_QueryInterface(proxy);
85
NS_ENSURE_ARG(pi);
86
87
pi.swap(mNext);
88
return NS_OK;
89
}
90
91
// These pointers are declared in nsProtocolProxyService.cpp and
92
// comparison of mType by string pointer is valid within necko
93
extern const char kProxyType_HTTP[];
94
extern const char kProxyType_HTTPS[];
95
extern const char kProxyType_SOCKS[];
96
extern const char kProxyType_SOCKS4[];
97
extern const char kProxyType_SOCKS5[];
98
extern const char kProxyType_DIRECT[];
99
100
bool nsProxyInfo::IsDirect() {
101
if (!mType) return true;
102
return mType == kProxyType_DIRECT;
103
}
104
105
bool nsProxyInfo::IsHTTP() { return mType == kProxyType_HTTP; }
106
107
bool nsProxyInfo::IsHTTPS() { return mType == kProxyType_HTTPS; }
108
109
bool nsProxyInfo::IsSOCKS() {
110
return mType == kProxyType_SOCKS || mType == kProxyType_SOCKS4 ||
111
mType == kProxyType_SOCKS5;
112
}
113
114
} // namespace net
115
} // namespace mozilla