/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
 *
 * The contents of this file are subject to the Netscape Public License
 * Version 1.0 (the "NPL"); you may not use this file except in
 * compliance with the NPL.  You may obtain a copy of the NPL at
 * http://www.mozilla.org/NPL/
 *
 * Software distributed under the NPL is distributed on an "AS IS" basis,
 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
 * for the specific language governing rights and limitations under the
 * NPL.
 *
 * The Initial Developer of this code under the NPL is Netscape
 * Communications Corporation.  Portions created by Netscape are
 * Copyright (C) 1998 Netscape Communications Corporation.  All Rights
 * Reserved.
 */

/*
 * The nsIMsgSend method will create an RFC822 message and send it all in one operation 
 * as well as providing the ability to save disk files for later use. The mode of delivery 
 * can also be specified for the "Send Later", "Drafts" and "Templates" operations. (NOTE: 
 * This method could easily be broken in to a few different calls. Currently, this method 
 * does several functions depending on the arguments passed in, but this could easily lead 
 * to confusion. This is something that very well may change as time allows). 
 */
#include "nsISupports.idl"
#include "nsISupportsArray.idl"
#include "nsrootidl.idl"
#include "nsIFileSpec.idl"
#include "nsIMsgIdentity.idl"
#include "nsIMsgCompFields.idl"
#include "nsIMsgSendListener.idl"

%{C++
#include "nsIMsgHdr.h"
#include "nsIURL.h"
#include "rosetta.h"
#include "rosetta_mailnews.h"
%}

interface	nsIURI;
interface nsIMessage;

typedef PRInt32 nsMsgDeliverMode;

%{ C++
enum
{
  nsMsgDeliverNow = 0,
  nsMsgQueueForLater = 1,
  nsMsgSave = 2,
  nsMsgSaveAs = 3,
  nsMsgSaveAsDraft = 4,
  nsMsgSaveAsTemplate = 5
} /* nsMsgDeliverMode */;
%}

%{ C++
//
// Callback declarations for message delivery
//
// For completion of send/message creation operations...
typedef nsresult (*nsMsgSendCompletionCallback) (nsresult aExitCode, void *tagData, nsFileSpec *returnFileSpec);

// For completion of sending unsent messages operations...
typedef nsresult (*nsMsgSendUnsentMessagesCallback) (nsresult aExitCode, PRUint32 totalSentCount,
                                                     PRUint32 totalSentSuccessfully, void *tagData);
%}

%{ C++
// Attachment file/URL structures
struct nsMsgAttachmentData
{
  nsIURI  *url;			        // The URL to attach. This should be 0 to signify "end of list".

  char *desired_type;	    // The type to which this document should be
						              // converted.  Legal values are NULL, TEXT_PLAIN
						              // and APPLICATION_POSTSCRIPT (which are macros
                          // defined in net.h); other values are ignored.

  char *real_type;		    // The type of the URL if known, otherwise NULL. For example, if 
                          // you were attaching a temp file which was known to contain HTML data, 
                          // you would pass in TEXT_HTML as the real_type, to override whatever type 
                          // the name of the tmp file might otherwise indicate.

  char *real_encoding;	  // Goes along with real_type 

  char *real_name;		    // The original name of this document, which will eventually show up in the 
                          // Content-Disposition header. For example, if you had copied a document to a 
                          // tmp file, this would be the original, human-readable name of the document.

  char *description;	    // If you put a string here, it will show up as the Content-Description header.  
                          // This can be any explanatory text; it's not a file name.						 

  char *x_mac_type, *x_mac_creator; // Mac-specific data that should show up as optional parameters
						                        // to the content-type header.
};


//
// When we have downloaded a URL to a tmp file for attaching, this
// represents everything we learned about it (and did to it) in the
// process. 
//
typedef struct nsMsgAttachedFile
{
  nsIURI      *orig_url;		// Where it came from on the network (or even elsewhere on the local disk.)

  nsFileSpec  *file_spec;		// The tmp file in which the (possibly converted) data now resides.
  
  char        *type;			  // The type of the data in file_name (not necessarily the same as the type of orig_url.)

  char        *encoding;		// Likewise, the encoding of the tmp file. This will be set only if the original 
                            // document had an encoding already; we don't do base64 encoding and so forth until 
                            // it's time to assemble a full MIME message of all parts.


  char        *description;	  // For Content-Description header 
  char        *x_mac_type;    // mac-specific info 
  char        *x_mac_creator; // mac-specific info 
  char        *real_name;		  // The real name of the file. 

  // Some statistics about the data that was written to the file, so that when
	// it comes time to compose a MIME message, we can make an informed decision
	// about what Content-Transfer-Encoding would be best for this attachment.
  // (If it's encoded already, we ignore this information and ship it as-is.)
  PRUint32    size;
  PRUint32    unprintable_count;
  PRUint32    highbit_count;
  PRUint32    ctl_count;
  PRUint32    null_count;
  PRUint32    max_line_length;
  
  HG68452

} nsMsgAttachedFile;
%}

[ptr] native sendListenerPtr(nsIMsgSendListener *);
[ptr] native nsMsgAttachmentData(nsMsgAttachmentData);
[ptr] native nsMsgAttachedFile(nsMsgAttachedFile);

[scriptable, uuid(9E9BD970-C5D6-11d2-8297-000000000000)]
interface nsIMsgSend : nsISupports 
{
  void CreateAndSendMessage(
                            in nsIMsgIdentity               aUserIdentity,
   						              in nsIMsgCompFields             fields,
  						              in PRBool                       digest_p,
  						              in PRBool                       dont_deliver_p,
  						              in nsMsgDeliverMode             mode, 
                            in nsIMessage                   msgToReplace,
        						        [const] in string               attachment1_type,
  						              [const] in string               attachment1_body,
  						              in PRUint32                     attachment1_body_length,
  						              [const] in nsMsgAttachmentData  attachments,
  						              [const] in nsMsgAttachedFile    preloaded_attachments,
  						              in voidStar                     relatedPart,
                            in sendListenerPtr              aListenerArray); /* nsIMsgSendListener Array */

  void SendMessageFile(
                       in nsIMsgIdentity       aUserIdentity,
   						         in nsIMsgCompFields     fields,
                       in nsIFileSpec          sendIFileSpec,
                       in PRBool               deleteSendFileOnCompletion,
  						         in PRBool               digest_p,
  						         in nsMsgDeliverMode     mode,
                       in nsIMessage           msgToReplace,
                       in sendListenerPtr      aListenerArray); /* nsIMsgSendListener Array */

  void SendWebPage(
                   in nsIMsgIdentity         aUserIdentity,
   						     in nsIMsgCompFields       fields,
                   in nsIURI                 url,
                   in nsMsgDeliverMode       mode,
                   in sendListenerPtr        aListenerArray); /* nsIMsgSendListener Array */

  void AddListener(in nsIMsgSendListener aListener);
  void RemoveListener(in nsIMsgSendListener aListener);
};
