/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
 *
 * 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 Netscape are
 * Copyright (C) 1998 Netscape Communications Corporation. All
 * Rights Reserved.
 *
 * Contributor(s): 
 */
 
#include "nsISupports.idl"
#include "nsIAbCard.idl"
#include "nsISupportsArray.idl"

[ptr] native nsFileSpec(nsFileSpec);
[ptr] native DIR_Server(DIR_Server);

%{C++
#include "nsFileSpec.h"
#include "nsDirPrefs.h"
%}

[scriptable, uuid(AA920C90-1DD1-11B2-96D3-AA81268ADAFC)]
interface nsIAbDirectory : nsISupports {

	// The name of the directory
    attribute wstring dirName;
    attribute unsigned long  lastModifiedDate;

	// Defines wether this directory is a mail
	// list or not
	attribute PRBool isMailList;


	// Get the children directories
	readonly attribute nsIEnumerator childNodes;

	// Get the cards associated with the directory
	// This will return the cards associated with
	// the mailing lists too
	readonly attribute nsIEnumerator childCards;


	// Deletes either a mailing list or a top
	// level directory, which also updates the
	// preferences
	void deleteDirectory(in nsIAbDirectory dierctory);

	// Delete the 
	void deleteCards(in nsISupportsArray cards);


	// Check if directory contains card
	boolean hasCard(in nsIAbCard cards);

	// Check if directory contains directory
	boolean hasDirectory(in nsIAbDirectory dir);

	// Creates a new card in the directory
	// with the properties defined by card
	nsIAbCard  addCard(in nsIAbCard card);
	nsIAbCard  dropCard(in nsIAbCard card);


	// Mail list specific
	//

	// This attribute servers two purposes 
	// depending if the directory is a mail list.
	// If not mail list directories are stored here
	// If so mail list card entries are stored here
	attribute nsISupportsArray addressLists;

	// Specific to a directory which stores mail lists
	//

	// Creates a new mailing list in the directory
	// with the properties defined by list
	void addMailList (in nsIAbDirectory list);

	// Specific to a directory which is a mail list
	//

	// listName is not needed, dirName could be used
	// instead
	attribute wstring listName;
	attribute wstring listNickName;
	attribute wstring description;

	// Adds a new mail list into the directory
	// defined by the uri
	void addMailListToDatabase(in string uri);

	// Edits an existing mail in the directory
	// defined by the uri
	void editMailListToDatabase(in string uri);

	// Copies mail list properties from the srcList
	void copyMailList(in nsIAbDirectory srcList);

	/*
		Only creates a top level address book
		which is stored in the preferences

		Need to change to factory based approach
		to create new address books

		This method should become redundant or 
		be only associated with card folders
	*/
	void createNewDirectory(in unsigned long prefCount,[array, size_is(prefCount)] in string prefName, [array, size_is(prefCount)] in wstring prefValue);

    /* create a directory by passing the display name and address book uri */
	void CreateDirectoryByURI(in wstring displayName, in string uri, in boolean migrating);

};
