mailnews/news/src/nsNntpMockChannel.h
author Mike Conley <mconley@mozilla.com>
Tue, 14 Aug 2012 10:10:26 -0400
changeset 12544 8ad0a8d8ffc9bfbc237c7fb54da56d809ef59a40
parent 12286 84ac3c71109811da751f0ef2d72108075938f094
child 13324 3f9b812e72471c2172bfde0ebbeeb210bf5f1a95
permissions -rw-r--r--
Bug 741728 - Previous conversations should be collapsed by default. r=florian, ui-r=florian, a=Standard8.

/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* 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/. */

#ifndef nsNntpMockChannel_h___
#define nsNntpMockChannel_h___

#include "nsIChannel.h"
#include "nsIMsgWindow.h"

#include "nsCOMPtr.h"
#include "nsStringGlue.h"

class nsNNTPProtocol;

class nsNntpMockChannel : public nsIChannel
{
public:
  NS_DECL_ISUPPORTS
  NS_DECL_NSICHANNEL
  NS_DECL_NSIREQUEST

  nsNntpMockChannel(nsIURI *aUri, nsIMsgWindow *aMsgWindow);
  nsNntpMockChannel(nsIURI *aUri, nsIMsgWindow *aMsgWindow,
                    nsISupports *aConsumer);
  virtual ~nsNntpMockChannel();

  nsresult AttachNNTPConnection(nsNNTPProtocol &protocol);
protected:
  // The URL we will be running
  nsCOMPtr<nsIURI> m_url;

  // Variables for arguments to pass into the opening phase.
  nsCOMPtr<nsIStreamListener> m_channelListener;
  nsCOMPtr<nsISupports> m_context;
  nsCOMPtr<nsIMsgWindow> m_msgWindow;

  // The state we're in
  enum
  {
    CHANNEL_UNOPENED,        //!< No one bothered to open this yet
    CHANNEL_OPEN_WITH_LOAD,  //!< We should open with LoadNewsUrl
    CHANNEL_OPEN_WITH_ASYNC, //!< We should open with AsyncOpen
    CHANNEL_CLOSED           //!< We were closed and should not open
  } m_channelState;

  // The protocol instance
  nsNNTPProtocol *m_protocol;

  // Temporary variables for accessors before we get to the actual instance.
  nsresult m_cancelStatus;
  nsCOMPtr<nsILoadGroup> m_loadGroup;
  nsLoadFlags m_loadFlags;

  nsCOMPtr<nsIURI> m_originalUrl;
  nsCOMPtr<nsISupports> m_owner;
  nsCOMPtr<nsIInterfaceRequestor> m_notificationCallbacks;
  nsCString m_contentType;
  nsCString m_contentCharset;
  PRInt64 m_contentLength;
};

#endif  // nsNntpMockChannel_h___