netwerk/base/src/nsProxyInfo.cpp

branch
TOR_BUG_9701
changeset 15
b8a032363ba2
equal deleted inserted replaced
-1:000000000000 0:4ba7a696ba1f
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 // Yes, we support QI to nsProxyInfo
11 NS_IMPL_ISUPPORTS(nsProxyInfo, nsProxyInfo, nsIProxyInfo)
12
13 using namespace mozilla;
14
15 NS_IMETHODIMP
16 nsProxyInfo::GetHost(nsACString &result)
17 {
18 result = mHost;
19 return NS_OK;
20 }
21
22 NS_IMETHODIMP
23 nsProxyInfo::GetPort(int32_t *result)
24 {
25 *result = mPort;
26 return NS_OK;
27 }
28
29 NS_IMETHODIMP
30 nsProxyInfo::GetType(nsACString &result)
31 {
32 result = mType;
33 return NS_OK;
34 }
35
36 NS_IMETHODIMP
37 nsProxyInfo::GetFlags(uint32_t *result)
38 {
39 *result = mFlags;
40 return NS_OK;
41 }
42
43 NS_IMETHODIMP
44 nsProxyInfo::GetResolveFlags(uint32_t *result)
45 {
46 *result = mResolveFlags;
47 return NS_OK;
48 }
49
50 NS_IMETHODIMP
51 nsProxyInfo::GetUsername(nsACString &result)
52 {
53 result = mUsername;
54 return NS_OK;
55 }
56
57 NS_IMETHODIMP
58 nsProxyInfo::GetPassword(nsACString &result)
59 {
60 result = mPassword;
61 return NS_OK;
62 }
63
64 NS_IMETHODIMP
65 nsProxyInfo::GetFailoverTimeout(uint32_t *result)
66 {
67 *result = mTimeout;
68 return NS_OK;
69 }
70
71 NS_IMETHODIMP
72 nsProxyInfo::GetFailoverProxy(nsIProxyInfo **result)
73 {
74 NS_IF_ADDREF(*result = mNext);
75 return NS_OK;
76 }
77
78 NS_IMETHODIMP
79 nsProxyInfo::SetFailoverProxy(nsIProxyInfo *proxy)
80 {
81 nsCOMPtr<nsProxyInfo> pi = do_QueryInterface(proxy);
82 NS_ENSURE_ARG(pi);
83
84 pi.swap(mNext);
85 return NS_OK;
86 }
87
88 // These pointers are declared in nsProtocolProxyService.cpp and
89 // comparison of mType by string pointer is valid within necko
90 namespace mozilla {
91 extern const char kProxyType_HTTP[];
92 extern const char kProxyType_SOCKS[];
93 extern const char kProxyType_SOCKS4[];
94 extern const char kProxyType_SOCKS5[];
95 extern const char kProxyType_DIRECT[];
96 }
97
98 bool
99 nsProxyInfo::IsDirect()
100 {
101 if (!mType)
102 return true;
103 return mType == kProxyType_DIRECT;
104 }
105
106 bool
107 nsProxyInfo::IsHTTP()
108 {
109 return mType == kProxyType_HTTP;
110 }
111
112 bool
113 nsProxyInfo::IsSOCKS()
114 {
115 return mType == kProxyType_SOCKS ||
116 mType == kProxyType_SOCKS4 || mType == kProxyType_SOCKS5;
117 }
118

mercurial