netwerk/base/src/nsProxyInfo.cpp

Thu, 22 Jan 2015 13:21:57 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 22 Jan 2015 13:21:57 +0100
branch
TOR_BUG_9701
changeset 15
b8a032363ba2
permissions
-rw-r--r--

Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6

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

mercurial