netwerk/base/src/nsProxyInfo.cpp
author seabld
Tue, 10 Dec 2013 19:46:44 -0800
branchSEA_COMM260_20131210_RELBRANCH
changeset 162115 18f4223296d02d37b6a08e6455fc00be83d05e74
parent 152784 14bd6018f287849d5a43f0238cb01e9b1a81e29e
child 185558 2785a168194e5f8fe258d128ed264230a180a093
permissions -rw-r--r--
Added tag SEAMONKEY_2_23_RELEASE for changeset c6bc408104a2. CLOSED TREE a=release

/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim:set ts=2 sw=2 sts=2 et cindent: */
/* This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */

#include "nsProxyInfo.h"
#include "nsCOMPtr.h"

// Yes, we support QI to nsProxyInfo
NS_IMPL_ISUPPORTS2(nsProxyInfo, nsProxyInfo, nsIProxyInfo) 

using namespace mozilla;

NS_IMETHODIMP
nsProxyInfo::GetHost(nsACString &result)
{
  result = mHost;
  return NS_OK;
}

NS_IMETHODIMP
nsProxyInfo::GetPort(int32_t *result)
{
  *result = mPort;
  return NS_OK;
}

NS_IMETHODIMP
nsProxyInfo::GetType(nsACString &result)
{
  result = mType;
  return NS_OK;
}

NS_IMETHODIMP
nsProxyInfo::GetFlags(uint32_t *result)
{
  *result = mFlags;
  return NS_OK;
}

NS_IMETHODIMP
nsProxyInfo::GetResolveFlags(uint32_t *result)
{
  *result = mResolveFlags;
  return NS_OK;
}

NS_IMETHODIMP
nsProxyInfo::GetFailoverTimeout(uint32_t *result)
{
  *result = mTimeout;
  return NS_OK;
}

NS_IMETHODIMP
nsProxyInfo::GetFailoverProxy(nsIProxyInfo **result)
{
  NS_IF_ADDREF(*result = mNext);
  return NS_OK;
}

NS_IMETHODIMP
nsProxyInfo::SetFailoverProxy(nsIProxyInfo *proxy)
{
  nsCOMPtr<nsProxyInfo> pi = do_QueryInterface(proxy);
  NS_ENSURE_ARG(pi);

  pi.swap(mNext);
  return NS_OK;
}

// These pointers are declared in nsProtocolProxyService.cpp and
// comparison of mType by string pointer is valid within necko
namespace mozilla {
  extern const char *kProxyType_HTTP;
  extern const char *kProxyType_SOCKS;
  extern const char *kProxyType_SOCKS4;
  extern const char *kProxyType_SOCKS5;
  extern const char *kProxyType_DIRECT;
}

bool
nsProxyInfo::IsDirect()
{
  if (!mType)
    return true;
  return mType == kProxyType_DIRECT;
}

bool
nsProxyInfo::IsHTTP()
{
  return mType == kProxyType_HTTP;
}

bool
nsProxyInfo::IsSOCKS()
{
  return mType == kProxyType_SOCKS ||
    mType == kProxyType_SOCKS4 || mType == kProxyType_SOCKS5;
}