1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/netwerk/base/src/nsProxyInfo.cpp Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,118 @@ 1.4 +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ 1.5 +/* vim:set ts=2 sw=2 sts=2 et cindent: */ 1.6 +/* This Source Code Form is subject to the terms of the Mozilla Public 1.7 + * License, v. 2.0. If a copy of the MPL was not distributed with this 1.8 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 1.9 + 1.10 +#include "nsProxyInfo.h" 1.11 +#include "nsCOMPtr.h" 1.12 + 1.13 +// Yes, we support QI to nsProxyInfo 1.14 +NS_IMPL_ISUPPORTS(nsProxyInfo, nsProxyInfo, nsIProxyInfo) 1.15 + 1.16 +using namespace mozilla; 1.17 + 1.18 +NS_IMETHODIMP 1.19 +nsProxyInfo::GetHost(nsACString &result) 1.20 +{ 1.21 + result = mHost; 1.22 + return NS_OK; 1.23 +} 1.24 + 1.25 +NS_IMETHODIMP 1.26 +nsProxyInfo::GetPort(int32_t *result) 1.27 +{ 1.28 + *result = mPort; 1.29 + return NS_OK; 1.30 +} 1.31 + 1.32 +NS_IMETHODIMP 1.33 +nsProxyInfo::GetType(nsACString &result) 1.34 +{ 1.35 + result = mType; 1.36 + return NS_OK; 1.37 +} 1.38 + 1.39 +NS_IMETHODIMP 1.40 +nsProxyInfo::GetFlags(uint32_t *result) 1.41 +{ 1.42 + *result = mFlags; 1.43 + return NS_OK; 1.44 +} 1.45 + 1.46 +NS_IMETHODIMP 1.47 +nsProxyInfo::GetResolveFlags(uint32_t *result) 1.48 +{ 1.49 + *result = mResolveFlags; 1.50 + return NS_OK; 1.51 +} 1.52 + 1.53 +NS_IMETHODIMP 1.54 +nsProxyInfo::GetUsername(nsACString &result) 1.55 +{ 1.56 + result = mUsername; 1.57 + return NS_OK; 1.58 +} 1.59 + 1.60 +NS_IMETHODIMP 1.61 +nsProxyInfo::GetPassword(nsACString &result) 1.62 +{ 1.63 + result = mPassword; 1.64 + return NS_OK; 1.65 +} 1.66 + 1.67 +NS_IMETHODIMP 1.68 +nsProxyInfo::GetFailoverTimeout(uint32_t *result) 1.69 +{ 1.70 + *result = mTimeout; 1.71 + return NS_OK; 1.72 +} 1.73 + 1.74 +NS_IMETHODIMP 1.75 +nsProxyInfo::GetFailoverProxy(nsIProxyInfo **result) 1.76 +{ 1.77 + NS_IF_ADDREF(*result = mNext); 1.78 + return NS_OK; 1.79 +} 1.80 + 1.81 +NS_IMETHODIMP 1.82 +nsProxyInfo::SetFailoverProxy(nsIProxyInfo *proxy) 1.83 +{ 1.84 + nsCOMPtr<nsProxyInfo> pi = do_QueryInterface(proxy); 1.85 + NS_ENSURE_ARG(pi); 1.86 + 1.87 + pi.swap(mNext); 1.88 + return NS_OK; 1.89 +} 1.90 + 1.91 +// These pointers are declared in nsProtocolProxyService.cpp and 1.92 +// comparison of mType by string pointer is valid within necko 1.93 +namespace mozilla { 1.94 + extern const char kProxyType_HTTP[]; 1.95 + extern const char kProxyType_SOCKS[]; 1.96 + extern const char kProxyType_SOCKS4[]; 1.97 + extern const char kProxyType_SOCKS5[]; 1.98 + extern const char kProxyType_DIRECT[]; 1.99 +} 1.100 + 1.101 +bool 1.102 +nsProxyInfo::IsDirect() 1.103 +{ 1.104 + if (!mType) 1.105 + return true; 1.106 + return mType == kProxyType_DIRECT; 1.107 +} 1.108 + 1.109 +bool 1.110 +nsProxyInfo::IsHTTP() 1.111 +{ 1.112 + return mType == kProxyType_HTTP; 1.113 +} 1.114 + 1.115 +bool 1.116 +nsProxyInfo::IsSOCKS() 1.117 +{ 1.118 + return mType == kProxyType_SOCKS || 1.119 + mType == kProxyType_SOCKS4 || mType == kProxyType_SOCKS5; 1.120 +} 1.121 +