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::SetResolveFlags(uint32_t flags) {
48
mResolveFlags = flags;
49
return NS_OK;
50
}
51
52
NS_IMETHODIMP
53
nsProxyInfo::GetUsername(nsACString& result) {
54
result = mUsername;
55
return NS_OK;
56
}
57
58
NS_IMETHODIMP
59
nsProxyInfo::GetPassword(nsACString& result) {
60
result = mPassword;
61
return NS_OK;
62
}
63
64
NS_IMETHODIMP
65
nsProxyInfo::GetProxyAuthorizationHeader(nsACString& result) {
66
result = mProxyAuthorizationHeader;
67
return NS_OK;
68
}
69
70
NS_IMETHODIMP
71
nsProxyInfo::GetConnectionIsolationKey(nsACString& result) {
72
result = mConnectionIsolationKey;
73
return NS_OK;
74
}
75
76
NS_IMETHODIMP
77
nsProxyInfo::GetFailoverTimeout(uint32_t* result) {
78
*result = mTimeout;
79
return NS_OK;
80
}
81
82
NS_IMETHODIMP
83
nsProxyInfo::GetFailoverProxy(nsIProxyInfo** result) {
84
NS_IF_ADDREF(*result = mNext);
85
return NS_OK;
86
}
87
88
NS_IMETHODIMP
89
nsProxyInfo::SetFailoverProxy(nsIProxyInfo* proxy) {
90
nsCOMPtr<nsProxyInfo> pi = do_QueryInterface(proxy);
91
NS_ENSURE_ARG(pi);
92
93
pi.swap(mNext);
94
return NS_OK;
95
}
96
97
// These pointers are declared in nsProtocolProxyService.cpp and
98
// comparison of mType by string pointer is valid within necko
99
extern const char kProxyType_HTTP[];
100
extern const char kProxyType_HTTPS[];
101
extern const char kProxyType_SOCKS[];
102
extern const char kProxyType_SOCKS4[];
103
extern const char kProxyType_SOCKS5[];
104
extern const char kProxyType_DIRECT[];
105
106
bool nsProxyInfo::IsDirect() {
107
if (!mType) return true;
108
return mType == kProxyType_DIRECT;
109
}
110
111
bool nsProxyInfo::IsHTTP() { return mType == kProxyType_HTTP; }
112
113
bool nsProxyInfo::IsHTTPS() { return mType == kProxyType_HTTPS; }
114
115
bool nsProxyInfo::IsSOCKS() {
116
return mType == kProxyType_SOCKS || mType == kProxyType_SOCKS4 ||
117
mType == kProxyType_SOCKS5;
118
}
119
120
} // namespace net
121
} // namespace mozilla