/* -*- 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): 
 */

/* nsFileSpec is declared in nsIAbDirectory.idl */
#include "nsIAddrDBAnnouncer.idl"
#include "nsIAbCard.idl"
#include "nsIAbDirectory.idl"

%{C++
#include "mdb.h"
#include "nsString.h"
%}

[ptr] native nsIMdbTableRowCursor(nsIMdbTableRowCursor);
[ptr] native nsIMdbEnv(nsIMdbEnv);
[ptr] native nsIMdbRow(nsIMdbRow);
[ref] native nsStringRef(nsString);


[scriptable, uuid(A4186D8B-1DD0-11d3-A303-001083003D0C)] 
interface nsIAddrDatabase : nsIAddrDBAnnouncer {

	[noscript] attribute nsFileSpec dbPath;
	[noscript] void open(in nsFileSpec folderName, in boolean create,
						out nsIAddrDatabase pCardDB, in boolean upgrading);
	void close(in boolean forceCommit);
	[noscript] void openMDB(in nsFileSpec dbName, in boolean create);
	void closeMDB(in boolean commit);
	void openAnonymousDB(out nsIAddrDatabase pCardDB);
	void closeAnonymousDB(in boolean forceCommit);

	void commit(in unsigned long commitType);
	void forceClosed();

	void createNewCardAndAddToDB(in nsIAbCard newCard, in boolean beNotify);
	void createNewCardAndAddToDBWithKey(in nsIAbCard newCard, in boolean beNotify, out unsigned long key);	
	void createNewListCardAndAddToDB(in unsigned long listRowID, in nsIAbCard newCard, in boolean beNotify);
	void createMailListAndAddToDB(in nsIAbDirectory newList, in boolean beNotify);
	nsIEnumerator enumerateCards(in nsIAbDirectory directory);
	nsIEnumerator enumerateListAddresses(in nsIAbDirectory directory);
	void getMailingListsFromDB(in nsIAbDirectory parentDir);
	void deleteCard(in nsIAbCard card, in boolean beNotify);
	void editCard(in nsIAbCard card, in boolean beNotify);
	boolean containsCard(in nsIAbCard card);
	void deleteMailList(in nsIAbDirectory mailList, in boolean beNotify);
	void editMailList(in nsIAbDirectory mailList, in boolean beNotify);
	boolean containsMailList(in nsIAbDirectory mailList);
	void deleteCardFromMailList(in nsIAbDirectory mailList, in nsIAbCard card, in boolean beNotify);
	wstring getDirectoryName();

	nsIAbCard getCardForEmailAddress(in nsIAbDirectory directory, in string emailAddress);

	PRBool findMailListbyUnicodeName(in wstring listName);

	void getCardCount(out PRUint32 count);
	void RemoveExtraCardsInCab(in PRUint32 cardTotal, in PRUint32 cabMax);

	void setAnonymousStringAttribute(in string attrname, in string value);
	string getAnonymousStringAttribute(in string attrname);
	void setAnonymousIntAttribute(in string attrname, in unsigned long value);
	unsigned long getAnonymousIntAttribute(in string attrname);
	void setAnonymousBoolAttribute(in string attrname, in boolean value);
	boolean getAnonymousBoolAttribute(in string attrname);
	void addAnonymousAttributesToDB();
	void removeAnonymousAttributesFromDB();
	void editAnonymousAttributesInDB();
	void addAnonymousAttributesFromCard(in nsIAbCard card);
	void removeAnonymousAttributesFromCard(in nsIAbCard card);
	void editAnonymousAttributesFromCard(in nsIAbCard card);

	[noscript] readonly attribute nsIMdbRow newRow;
	[noscript] readonly attribute nsIMdbRow newListRow;
	[noscript] void addCardRowToDB(in nsIMdbRow newRow);
	[noscript] void addLdifListMember(in nsIMdbRow row, in string value);
	[noscript] void addFirstName(in nsIMdbRow row, in string value);
	[noscript] void addLastName(in nsIMdbRow row, in string value);
	[noscript] void addDisplayName(in nsIMdbRow row, in string value);
	[noscript] void addNickName(in nsIMdbRow row, in string value);
	[noscript] void addPrimaryEmail(in nsIMdbRow row, in string value);
	[noscript] void add2ndEmail(in nsIMdbRow row, in string value);
	[noscript] void addWorkPhone(in nsIMdbRow row, in string value);
	[noscript] void addHomePhone(in nsIMdbRow row, in string value);
	[noscript] void addFaxNumber(in nsIMdbRow row, in string value);
	[noscript] void addPagerNumber(in nsIMdbRow row, in string value);
	[noscript] void addCellularNumber(in nsIMdbRow row, in string value);
	[noscript] void addHomeAddress(in nsIMdbRow row, in string value);
	[noscript] void addHomeAddress2(in nsIMdbRow row, in string value);
	[noscript] void addHomeCity(in nsIMdbRow row, in string value);
	[noscript] void addHomeState(in nsIMdbRow row, in string value);
	[noscript] void addHomeZipCode(in nsIMdbRow row, in string value);
	[noscript] void addHomeCountry(in nsIMdbRow row, in string value);
	[noscript] void addWorkAddress(in nsIMdbRow row, in string value);
	[noscript] void addWorkAddress2(in nsIMdbRow row, in string value);
	[noscript] void addWorkCity(in nsIMdbRow row, in string value);
	[noscript] void addWorkState(in nsIMdbRow row, in string value);
	[noscript] void addWorkZipCode(in nsIMdbRow row, in string value);
	[noscript] void addWorkCountry(in nsIMdbRow row, in string value);
	[noscript] void addJobTitle(in nsIMdbRow row, in string value);
	[noscript] void addDepartment(in nsIMdbRow row, in string value);
	[noscript] void addCompany(in nsIMdbRow row, in string value);
	[noscript] void addWebPage1(in nsIMdbRow row, in string value);
	[noscript] void addWebPage2(in nsIMdbRow row, in string value);
	[noscript] void addBirthYear(in nsIMdbRow row, in string value);
	[noscript] void addBirthMonth(in nsIMdbRow row, in string value);
	[noscript] void addBirthDay(in nsIMdbRow row, in string value);
	[noscript] void addCustom1(in nsIMdbRow row, in string value);
	[noscript] void addCustom2(in nsIMdbRow row, in string value);
	[noscript] void addCustom3(in nsIMdbRow row, in string value);
	[noscript] void addCustom4(in nsIMdbRow row, in string value);
	[noscript] void addNotes(in nsIMdbRow row, in string value);
	[noscript] void addPreferMailFormat(in nsIMdbRow row, in unsigned long value);

	[noscript] void addListName(in nsIMdbRow row, in string value);
	[noscript] void addListNickName(in nsIMdbRow row, in string value);
	[noscript] void addListDescription(in nsIMdbRow row, in string value);
	[noscript] void AddListDirNode(in nsIMdbRow listRow);
 
	[noscript] void createCollationKey(in wstring sourceStr, in nsStringRef resultStr);

};
