/* -*- Mode: IDL; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
 * Version: NPL 1.1/GPL 2.0/LGPL 2.1
 *
 * The contents of this file are subject to the Netscape Public License
 * Version 1.1 (the "License"); you may not use this file except in
 * compliance with the License. You may obtain a copy of the License at
 * http://www.mozilla.org/NPL/
 *
 * Software distributed under the License is distributed on an "AS IS" basis,
 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
 * for the specific language governing rights and limitations under the
 * License.
 *
 * The Original Code is mozilla.org code.
 *
 * The Initial Developer of the Original Code is 
 * Netscape Communications Corporation.
 * Portions created by the Initial Developer are Copyright (C) 1998
 * the Initial Developer. All Rights Reserved.
 *
 * Contributor(s):
 *
 * Alternatively, the contents of this file may be used under the terms of
 * either the GNU General Public License Version 2 or later (the "GPL"), or 
 * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
 * in which case the provisions of the GPL or the LGPL are applicable instead
 * of those above. If you wish to allow use of your version of this file only
 * under the terms of either the GPL or the LGPL, and not to allow others to
 * use your version of this file under the terms of the NPL, indicate your
 * decision by deleting the provisions above and replace them with the notice
 * and other provisions required by the GPL or the LGPL. If you do not delete
 * the provisions above, a recipient may use your version of this file under
 * the terms of any one of the NPL, the GPL or the LGPL.
 *
 * ***** END LICENSE BLOCK ***** */

#include "nsISupports.idl"

interface nsIURI;
interface nsIUrlListener;
interface nsIStreamListener;
interface nsIMsgWindow;
interface nsIFileSpec;
interface nsIMsgFolder;
interface nsIMsgSearchSession;
interface nsIMsgDBHdr;
interface nsIStreamConverter;

%{C++
#include "nsMsgKeyArray.h"
%}

[ptr] native nsMsgKeyArrayPtr(nsMsgKeyArray);


[scriptable, uuid(F11009C1-F697-11d2-807F-006008128C4E)]
interface nsIMsgMessageService : nsISupports {
     
     /////////////////////////////////////////////////////////////////
     // If you want a handle on the running task, pass in a valid nsIURI 
     // ptr. You can later interrupt this action by asking the netlib 
     // service manager to interrupt the url you are given back. 
     // Remember to release aURL when you are done with it. Pass nsnull
     // in for aURL if you don't  care about the returned URL.
     /////////////////////////////////////////////////////////////////


     /////////////////////////////////////////////////////////////////
     // CopyMessage: Pass in the URI for the message you want to have 
     // copied.
     // aCopyListener already knows about the destination folder. 
     // Set aMoveMessage to PR_TRUE if you want the message to be moved.
     // PR_FALSE leaves it as just a copy.
     ///////////////////////////////////////////////////////////////
  
	void CopyMessage(in string aSrcURI, in nsIStreamListener aCopyListener, in boolean aMoveMessage,
						   in nsIUrlListener aUrlListener, in nsIMsgWindow aMsgWindow, out nsIURI aURL);

    /* copy multiple messages at a time */
	[noscript] void CopyMessages(in nsMsgKeyArrayPtr keys, in nsIMsgFolder srcFolder, in nsIStreamListener aCopyListener, in boolean aMoveMessage,
						   in nsIUrlListener aUrlListener, in nsIMsgWindow aMsgWindow, out nsIURI aURL);

    /////////////////////////////////////////////////////////////////////
    //  DisplayMessage: When you want a message displayed....
    //  aMessageURI	  is a uri representing the message to display.
    //  aDisplayConsumer is (for now) a nsIWebshell which we'll use to load 
    //  the message into. 
	  //	aCharsetOverride  (optional) character set over ride to force the message to
	  //  use.
	  //
    ///////////////////////////////////////////////////////////////////

	void DisplayMessage(in string aMessageURI, 
						in nsISupports aDisplayConsumer, 
						in nsIMsgWindow aMsgWindow,
						in nsIUrlListener aUrlListener, 
						in string aCharsetOverride, 
						out nsIURI aURL);

     /////////////////////////////////////////////////////////////////////
     //  OpenAttachment: When you want an attachment downloaded
     //  aContentType --> we need to know the content type of the attachment
	 //	 aFileName --> the name of the attachment.
	 //	 aUrl --> string representation of the original url associated with the msg.
	 //  aMessageUri --> RDF resource that describes the message
	 //	 aMsgWindow --> message window
     ///////////////////////////////////////////////////////////////////

	void openAttachment(in string aContentType, 
						in string aFileName, 
						in string aUrl,
						in string aMessageUri, 
						in nsISupports aDisplayConsumer, 
						in nsIMsgWindow aMsgWindow,
						in nsIUrlListener aUrlListener);

     /////////////////////////////////////////////////////////////////////
     // SaveMessageToDisk: When you want to spool a message out to a file
	 // on disk. This is an asynch operation of course. You must pass in a
	 // url listener in order to figure out when the operation is done.
	 // aMessageURI--> uri representing the message to spool out to disk.
	 // aFile - the file you want the message saved to
	 // aGenerateDummyEnvelope --> usually FALSE. Set to TRUE if you want the msg
	 //					  appended at the end of the file. 
     ///////////////////////////////////////////////////////////////////

  void SaveMessageToDisk(in string aMessageURI, in nsIFileSpec aFile,
                         in boolean aGenerateDummyEnvelope, 
                         in nsIUrlListener aUrlListener, out nsIURI aURL,
                         in boolean canonicalLineEnding, in nsIMsgWindow aMsgWindow);

    /////////////////////////////////////////////////////////////////////
	// GetUrlForUri: when you have a uri and you would like to convert that
	// to a url which can be run through necko, you can use this method.
	// the Uri MUST refer to a message and not a folder! 
    /////////////////////////////////////////////////////////////////////
    
	void GetUrlForUri(in string aMessageURI, out nsIURI aURL, in nsIMsgWindow aMsgWindow);

     /////////////////////////////////////////////////////////////////////
     //  DisplayMessageForPrinting: When you want a message displayed in a
     //  format that is suitable for printing....
     //  aMessageURI is a uri representing the message to display.
     //  aDisplayConsumer is (for now) a nsIWebshell which we'll use to load 
     // the message into. 
     ///////////////////////////////////////////////////////////////////

	void DisplayMessageForPrinting(in string aMessageURI, in nsISupports aDisplayConsumer, 
						in nsIMsgWindow aMsgWindow,
						in nsIUrlListener aUrlListener, 
						out nsIURI aURL);

	void Search(in nsIMsgSearchSession aSearchSession, in nsIMsgWindow aMsgWindow, in nsIMsgFolder aMsgFolder, in string aSearchUri);

  // this method streams a message to the passed in consumer. If aConvertData is true, it
  // will create a stream converter from message rfc822 to star/star. It will also tack
  // aAdditionalHeader onto the url (e.g., "header=filter").
  // @param aMessageURI  uri of message to stream
  // @param aConsumer    generally, a stream listener listening to the message
  // @param aMsgWindow   msgWindow for give progress and status feedback
  // @param aUrlListener gets notified when url starts and stops
  // @param aConvertData should we create a stream converter?
  // @param aAdditionalHeader added to URI, e.g., "header=filter"
  // @return the URL that gets run
  nsIURI streamMessage(in string aMessageURI, in nsISupports aConsumer, 
                    in nsIMsgWindow aMsgWindow,
                    in nsIUrlListener aUrlListener, 
                    in boolean aConvertData,
                    in string aAdditionalHeader);
    /**
     * now the the message datasource is going away
     * we need away to go from message uri to go nsIMsgDBHdr
     */
    nsIMsgDBHdr messageURIToMsgHdr(in string uri);
};

// Some mail protocols (like imap) allow you to fetch individual mime parts. We use this interface
// to represent message services whose protocols support this. To use this interface, you should get
// the message service then QI for this interface. If it's present, then can fetch a mime part.
[scriptable, uuid(3728C255-480C-11d4-98D0-001083010E9B)]
interface nsIMsgMessageFetchPartService : nsISupports 
{
	// FetchMimePart --> used to fetch an individual mime part
	// aURI --> url representing the message
	// aMessageURI --> RDF URI including the part to fetch
	nsIURI fetchMimePart(in nsIURI aURI, in string aMessageUri, in nsISupports aDisplayConsumer, 
						in nsIMsgWindow aMsgWindow,
						in nsIUrlListener aUrlListener);	
};
