From 6bf0a5cb5034a7e684dcc3500e841785237ce2dd Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sun, 7 Apr 2024 19:32:43 +0200 Subject: Adding upstream version 1:115.7.0. Signed-off-by: Daniel Baumann --- comm/mailnews/addrbook/public/moz.build | 48 +++ .../addrbook/public/nsIAbAddressCollector.idl | 46 +++ .../addrbook/public/nsIAbAutoCompleteResult.idl | 51 +++ .../addrbook/public/nsIAbBooleanExpression.idl | 120 ++++++ comm/mailnews/addrbook/public/nsIAbCard.idl | 402 ++++++++++++++++++ .../addrbook/public/nsIAbDirSearchListener.idl | 40 ++ comm/mailnews/addrbook/public/nsIAbDirectory.idl | 371 +++++++++++++++++ .../addrbook/public/nsIAbDirectoryQuery.idl | 133 ++++++ .../addrbook/public/nsIAbDirectoryQueryProxy.idl | 13 + .../addrbook/public/nsIAbLDAPAttributeMap.idl | 192 +++++++++ .../addrbook/public/nsIAbLDAPDirectory.idl | 97 +++++ .../addrbook/public/nsIAbLDAPReplicationData.idl | 54 +++ .../addrbook/public/nsIAbLDAPReplicationQuery.idl | 63 +++ .../public/nsIAbLDAPReplicationService.idl | 31 ++ comm/mailnews/addrbook/public/nsIAbLDIFService.idl | 43 ++ comm/mailnews/addrbook/public/nsIAbManager.idl | 132 ++++++ .../addrbook/public/nsIAbOutlookInterface.idl | 12 + .../mailnews/addrbook/public/nsILDAPBERElement.idl | 122 ++++++ comm/mailnews/addrbook/public/nsILDAPBERValue.idl | 41 ++ .../mailnews/addrbook/public/nsILDAPConnection.idl | 77 ++++ comm/mailnews/addrbook/public/nsILDAPControl.idl | 45 +++ comm/mailnews/addrbook/public/nsILDAPErrors.idl | 447 +++++++++++++++++++++ comm/mailnews/addrbook/public/nsILDAPMessage.idl | 167 ++++++++ .../addrbook/public/nsILDAPMessageListener.idl | 48 +++ .../addrbook/public/nsILDAPModification.idl | 57 +++ comm/mailnews/addrbook/public/nsILDAPOperation.idl | 278 +++++++++++++ comm/mailnews/addrbook/public/nsILDAPService.idl | 43 ++ comm/mailnews/addrbook/public/nsILDAPSyncQuery.idl | 27 ++ comm/mailnews/addrbook/public/nsILDAPURL.idl | 170 ++++++++ .../addrbook/public/nsIMsgVCardService.idl | 36 ++ 30 files changed, 3406 insertions(+) create mode 100644 comm/mailnews/addrbook/public/moz.build create mode 100644 comm/mailnews/addrbook/public/nsIAbAddressCollector.idl create mode 100644 comm/mailnews/addrbook/public/nsIAbAutoCompleteResult.idl create mode 100644 comm/mailnews/addrbook/public/nsIAbBooleanExpression.idl create mode 100644 comm/mailnews/addrbook/public/nsIAbCard.idl create mode 100644 comm/mailnews/addrbook/public/nsIAbDirSearchListener.idl create mode 100644 comm/mailnews/addrbook/public/nsIAbDirectory.idl create mode 100644 comm/mailnews/addrbook/public/nsIAbDirectoryQuery.idl create mode 100644 comm/mailnews/addrbook/public/nsIAbDirectoryQueryProxy.idl create mode 100644 comm/mailnews/addrbook/public/nsIAbLDAPAttributeMap.idl create mode 100644 comm/mailnews/addrbook/public/nsIAbLDAPDirectory.idl create mode 100644 comm/mailnews/addrbook/public/nsIAbLDAPReplicationData.idl create mode 100644 comm/mailnews/addrbook/public/nsIAbLDAPReplicationQuery.idl create mode 100644 comm/mailnews/addrbook/public/nsIAbLDAPReplicationService.idl create mode 100644 comm/mailnews/addrbook/public/nsIAbLDIFService.idl create mode 100644 comm/mailnews/addrbook/public/nsIAbManager.idl create mode 100644 comm/mailnews/addrbook/public/nsIAbOutlookInterface.idl create mode 100644 comm/mailnews/addrbook/public/nsILDAPBERElement.idl create mode 100644 comm/mailnews/addrbook/public/nsILDAPBERValue.idl create mode 100644 comm/mailnews/addrbook/public/nsILDAPConnection.idl create mode 100644 comm/mailnews/addrbook/public/nsILDAPControl.idl create mode 100644 comm/mailnews/addrbook/public/nsILDAPErrors.idl create mode 100644 comm/mailnews/addrbook/public/nsILDAPMessage.idl create mode 100644 comm/mailnews/addrbook/public/nsILDAPMessageListener.idl create mode 100644 comm/mailnews/addrbook/public/nsILDAPModification.idl create mode 100644 comm/mailnews/addrbook/public/nsILDAPOperation.idl create mode 100644 comm/mailnews/addrbook/public/nsILDAPService.idl create mode 100644 comm/mailnews/addrbook/public/nsILDAPSyncQuery.idl create mode 100644 comm/mailnews/addrbook/public/nsILDAPURL.idl create mode 100644 comm/mailnews/addrbook/public/nsIMsgVCardService.idl (limited to 'comm/mailnews/addrbook/public') diff --git a/comm/mailnews/addrbook/public/moz.build b/comm/mailnews/addrbook/public/moz.build new file mode 100644 index 0000000000..ece3c8d37b --- /dev/null +++ b/comm/mailnews/addrbook/public/moz.build @@ -0,0 +1,48 @@ +# vim: set filetype=python: +# 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/. + +XPIDL_SOURCES += [ + "nsIAbAddressCollector.idl", + "nsIAbAutoCompleteResult.idl", + "nsIAbBooleanExpression.idl", + "nsIAbCard.idl", + "nsIAbDirectory.idl", + "nsIAbDirectoryQuery.idl", + "nsIAbDirectoryQueryProxy.idl", + "nsIAbDirSearchListener.idl", + "nsIAbLDAPAttributeMap.idl", + "nsIAbLDAPDirectory.idl", + "nsIAbLDAPReplicationData.idl", + "nsIAbLDAPReplicationQuery.idl", + "nsIAbLDAPReplicationService.idl", + "nsIAbLDIFService.idl", + "nsIAbManager.idl", + "nsILDAPBERElement.idl", + "nsILDAPBERValue.idl", + "nsILDAPConnection.idl", + "nsILDAPControl.idl", + "nsILDAPErrors.idl", + "nsILDAPMessage.idl", + "nsILDAPMessageListener.idl", + "nsILDAPModification.idl", + "nsILDAPOperation.idl", + "nsILDAPService.idl", + "nsILDAPURL.idl", + "nsIMsgVCardService.idl", +] + +if CONFIG["OS_ARCH"] == "WINNT" and CONFIG["MOZ_MAPI_SUPPORT"]: + XPIDL_SOURCES += [ + "nsIAbOutlookInterface.idl", + ] + +if CONFIG["MOZ_PREF_EXTENSIONS"]: + XPIDL_SOURCES += [ + "nsILDAPSyncQuery.idl", + ] + +XPIDL_MODULE = "addrbook" + +EXPORTS += [] diff --git a/comm/mailnews/addrbook/public/nsIAbAddressCollector.idl b/comm/mailnews/addrbook/public/nsIAbAddressCollector.idl new file mode 100644 index 0000000000..d1c90ca35d --- /dev/null +++ b/comm/mailnews/addrbook/public/nsIAbAddressCollector.idl @@ -0,0 +1,46 @@ +/* -*- Mode: IDL; 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/. */ + +#include "nsISupports.idl" + +/** + * nsIAbAddressCollector is the interface to the address collecter service. + * It will save and update the supplied addresses into the address book + * specified by the "mail.collect_addressbook" pref. + */ +[scriptable, uuid(069d3fba-37d4-4158-b401-a8efaeea0b66)] +interface nsIAbAddressCollector : nsISupports { + /** + * Collects email addresses into the address book. + * If a card already exists for the email, the first/last/display names + * will be updated if they are supplied alongside the address. + * If a card does not exist for the email it will be created if aCreateCard + * is true. + * + * @param aAddresses The list of emails (in standard header format) + * to collect into the address book. + * @param aCreateCard Set to true if a card should be created if the + * email address doesn't exist. + */ + void collectAddress(in AUTF8String aAddresses, in boolean aCreateCard); + + /** + * Collects a single name and email address into the address book. + * By default, it saves the address without checking for an existing one. + * See collectAddress for the general implementation. + * + * @param aEmail The email address to collect. + * @param aDisplayName The display name associated with the email address. + * @param aCreateCard Set to true if a card should be created if the + * email address doesn't exist (ignored if + * aSkipCheckExisting is true). + * @param aSkipCheckExisting Optional parameter, if this is set then the + * implementation will skip checking for an + * existing card, and just create a new card. + */ + void collectSingleAddress(in AUTF8String aEmail, in AUTF8String aDisplayName, + in boolean aCreateCard, + [optional] in boolean aSkipCheckExisting); +}; diff --git a/comm/mailnews/addrbook/public/nsIAbAutoCompleteResult.idl b/comm/mailnews/addrbook/public/nsIAbAutoCompleteResult.idl new file mode 100644 index 0000000000..ceeeeefe67 --- /dev/null +++ b/comm/mailnews/addrbook/public/nsIAbAutoCompleteResult.idl @@ -0,0 +1,51 @@ +/* -*- 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/. */ + +#include "nsIAutoCompleteResult.idl" + +interface nsIAbCard; +interface nsIAbDirectory; + +/** + * This interface is used to extend the nsIAutoCompleteResult interface to + * provide extra facilities for obtaining more details of the results of + * an address book search. + */ +[scriptable, uuid(c0d35623-f719-4e43-ae24-573e393f87f9)] +interface nsIAbAutoCompleteResult : nsIAutoCompleteResult { + /** + * Get the card from the result at the given index + */ + nsIAbCard getCardAt(in long index); + + /** + * Gets the email to use for the card within the result at the given index. + * This is the email that was matched against for the card where there are + * multiple email addresses on a card. + * + * @param index Index of the autocomplete result to return the value for. + * @result The email address to use from the card. + */ + AString getEmailToUse(in long index); + + /** + * Indicates whether the source that returned this result returned a + * complete result for the query. If true, refining the search will not + * trigger a new query, instead simply filtering the previous results. + * If false, the directory will be present in asyncDirectories. + */ + bool isCompleteResult(in long index); + + /** + * The template used to build the query for this search. Optional. + */ + attribute AString modelQuery; + + /** + * Asynchronous address books that were unable to return full results. + * This means that they need to be required rather than simply filtered. + */ + attribute Array asyncDirectories; +}; diff --git a/comm/mailnews/addrbook/public/nsIAbBooleanExpression.idl b/comm/mailnews/addrbook/public/nsIAbBooleanExpression.idl new file mode 100644 index 0000000000..37ab350bbc --- /dev/null +++ b/comm/mailnews/addrbook/public/nsIAbBooleanExpression.idl @@ -0,0 +1,120 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* 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/. */ + +#include "nsISupports.idl" + +typedef long nsAbBooleanConditionType; + +/** + * Condition types + * + * Constants defining the types of condition + * to obtain a boolean result of TRUE or FALSE + * + */ +[scriptable, uuid(F51387B1-5AEF-4A1C-830E-7CD3B02366CE)] +interface nsIAbBooleanConditionTypes : nsISupports +{ + const long Exists = 0; + const long DoesNotExist = 1; + const long Contains = 2; + const long DoesNotContain = 3; + const long Is = 4; + const long IsNot = 5; + const long BeginsWith = 6; + const long EndsWith = 7; + const long LessThan = 8; + const long GreaterThan = 9; + const long SoundsLike = 10; + const long RegExp = 11; +}; + + +typedef long nsAbBooleanOperationType; + +/* + * Operation types + * + * Constants defining the boolean operation that + * should be performed between two boolean expressions + * + */ +[scriptable, uuid(9bdd2e51-2be4-49a4-a558-36d1a812231a)] +interface nsIAbBooleanOperationTypes : nsISupports +{ + const long AND = 0; + const long OR = 1; + const long NOT = 2; +}; + + +/** + * String condition + * + * A string condition represents a leaf node in a + * boolean expression tree and represents + * test which will return TRUE or FALSE + * + * Condition is an expression which is a + * leaf node in a boolean expression tree + * + */ +[scriptable, uuid(C3869D72-CFD0-45F0-A0EC-3F67D83C7110)] +interface nsIAbBooleanConditionString : nsISupports +{ + /** + * The condition for how the a value + * should be compared + * + */ + attribute nsAbBooleanConditionType condition; + + /** + * The lhs of the condition + * + * Represents a property name which + * should be evaluated to obtain the + * lhs. + * + */ + attribute string name; + + /** + * The rhs of the condition + * + * [condition] value + * + */ + attribute wstring value; +}; + +/** + * N Boolean expression type + * + * Supports Unary Binary and N boolean expressions + * + * An operation represents a node in a boolean + * expression tree which may contain one or more + * child conditions or expressions + * + */ +[scriptable, uuid(223a9462-1aeb-4c1f-b069-5fc6278989b2)] +interface nsIAbBooleanExpression: nsISupports +{ + /** + * The boolean operation to be applied to + * results of all evaluated expressions + * + */ + attribute nsAbBooleanOperationType operation; + + /** + * List of peer expressions + * + * e1 [op] e2 [op] .... en + * + */ + attribute Array expressions; +}; diff --git a/comm/mailnews/addrbook/public/nsIAbCard.idl b/comm/mailnews/addrbook/public/nsIAbCard.idl new file mode 100644 index 0000000000..69acf7fa95 --- /dev/null +++ b/comm/mailnews/addrbook/public/nsIAbCard.idl @@ -0,0 +1,402 @@ +/* -*- 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/. */ + +#include "nsISupports.idl" + +interface nsIProperty; +interface nsIStringBundle; +interface nsIVariant; + +[scriptable, uuid(97448252-F189-11d4-A422-001083003D0C)] +interface nsIAbPreferMailFormat : nsISupports { + const unsigned long unknown = 0; + const unsigned long plaintext = 1; + const unsigned long html = 2; +}; + +/** + * An interface representing an address book card. + * + * None of these IDs will be reflected in the property collection. Neither + * nsIAbCard::properties, nsIAbCard::deleteProperty, nor any of the property + * getters and setters are able to interact with these properties. + * + * Fundamentally, a card is a collection of properties. Modifying a property in + * some way on a card does not change the backend used to store the card; the + * directory is required to do make the changes here. + * + * The following are the core properties that are used: + * - Names: + * - FirstName, LastName + * - PhoneticFirstName, PhoneticLastName + * - DisplayName, NickName + * - SpouseName, FamilyName + * - PrimaryEmail, SecondEmail + * - Home Contact: + * - HomeAddress, HomeAddress2, HomeCity, HomeState, HomeZipCode, HomeCountry + * - HomePhone, HomePhoneType + * - Work contact. Same as home, but with `Work' instead of `Home' + * - Other Contact: + * - FaxNumber, FaxNumberType + * - PagerNumber, PagerNumberType + * - CellularNumber, CellularNumberType + * - JobTitle, Department, Company + * - _AimScreenName + * - Dates: + * - AnniversaryYear, AnniversaryMonth, AnniversaryDay + * - BirthYear, BirthMonth, BirthDay + * - WebPage1 (work), WebPage2 (home) + * - Custom1, Custom2, Custom3, Custom4 + * - Notes + * - Integral properties: + * - LastModifiedDate + * - PopularityIndex + * - Photo properties: + * - PhotoName + * - PhotoType + * - PhotoURI + * + * The contract id for the standard implementation is + * \@mozilla.org/addressbook/cardproperty;1. + */ +[scriptable, uuid(9bddf024-5178-4097-894e-d84b4ddde101)] +interface nsIAbCard : nsISupports { + /** + * @{ + * These constants reflect the possible values of the + * mail.addr_book.lastnamefirst preferences. They are intended to be used in + * generateName, defined below. + */ + const unsigned long GENERATE_DISPLAY_NAME = 0; + const unsigned long GENERATE_LAST_FIRST_ORDER = 1; + const unsigned long GENERATE_FIRST_LAST_ORDER = 2; + /** @} */ + + /** + * Generate a name from the item for display purposes. + * + * If this item is an nsIAbCard, then it will use the aGenerateFormat option + * to determine the string to return. + * If this item is not an nsIAbCard, then the aGenerateFormat option may be + * ignored, and the displayName of the item returned. + * + * @param aGenerateFormat The format to generate as per the GENERATE_* + * constants above. + * @param aBundle An optional parameter that is a pointer to a string + * bundle that holds: + * chrome://messenger/locale/addressbook/addressBook.properties + * If this bundle is not supplied, then the function + * will obtain the bundle itself. If cached by the + * caller and supplied to this function, then + * performance will be improved over many calls. + * @return A string containing the generated name. + */ + AString generateName(in long aGenerateFormat, + [optional] in nsIStringBundle aBundle); + + /** + * The UID for the nsIAbDirectory containing this card. + * + * The directory considered to contain this card is the directory which + * produced this card (e.g., through nsIAbDirectory::getCardForProperty) or + * the last directory to modify this card, if another directory did so. If the + * last directory to modify this card deleted it, then this card is considered + * unassociated. + * + * If this card is not associated with a directory, this string will be empty. + * + * There is no standardized way to associate a card with multiple directories. + * + * Consumers of this interface outside of directory implementations SHOULD + * NOT, in general, modify this property. + */ + attribute AUTF8String directoryUID; + + /** + * A 128-bit unique identifier for this card. This can only be set if it is not + * already set. The getter sets a value if there is not one. + */ + attribute AUTF8String UID; + + /** + * A list of all the properties that this card has as an enumerator, whose + * members are all nsIProperty objects. + */ + readonly attribute Array properties; + + /** + * Returns a property for the given name. + * + * @param name The case-sensitive name of the property to get. + * @param defaultValue The value to return if the property does not exist. + * @exception NS_ERROR_NOT_AVAILABLE if the named property does not exist. + * @exception NS_ERROR_CANNOT_CONVERT_DATA if the property cannot be converted + * to the desired type. + */ + nsIVariant getProperty(in AUTF8String name, in nsIVariant defaultValue); + /** + * @{ + * Returns a property for the given name. Javascript callers should NOT use these, + * but use getProperty instead. XPConnect will do the type conversion automagically. + * + * These functions convert values in the same manner as the default + * implementation of nsIVariant. Of particular note is that boolean variables + * are converted to integers as in C/C++ (true is a non-zero value), so that + * false will be converted to a string of "0" and not "false." + * + * + * @param name The case-sensitive name of the property to get. + * @exception NS_ERROR_NOT_AVAILABLE if the named property does not exist. + * @exception NS_ERROR_CANNOT_CONVERT_DATA if the property cannot be converted + * to the desired type. + */ + AString getPropertyAsAString(in string name); + AUTF8String getPropertyAsAUTF8String(in string name); + unsigned long getPropertyAsUint32(in string name); + + /** + * Returns a property for the given name. + * + * @param name The case-sensitive name of the property to get. + * @param defaultValue The value to return if the property does not exist. + */ + boolean getPropertyAsBool(in string name, in boolean defaultValue); + + /** @} */ + + /** + * Assigns the given to value to the property of the given name. + * + * Should the property exist, its value will be overwritten. An + * implementation may impose additional semantic constraints for certain + * properties. However, such constraints might not be checked by this method. + * + * @warning A value MUST be convertible to a string; if this convention is not + * followed, consumers of cards may fail unpredictably or return incorrect + * results. + * + * @param name The case-sensitive name of the property to set. + * @param value The new value of the property. + */ + void setProperty(in AUTF8String name, in nsIVariant value); + + /** + * @{ + * Sets a property for the given name. Javascript callers should NOT use these, + * but use setProperty instead. XPConnect will do the type conversion automagically. + * + * These functions convert values in the same manner as the default + * implementation of nsIVariant. + */ + void setPropertyAsAString(in string name, in AString value); + void setPropertyAsAUTF8String(in string name, in AUTF8String value); + void setPropertyAsUint32(in string name, in unsigned long value); + void setPropertyAsBool(in string name, in boolean value); + + /** @} */ + + /** + * Deletes the property with the given name. + * + * Some properties may not be deleted. However, the implementation will not + * check this constraint at this method. If such a property is deleted, an + * error may be thrown when the card is modified at the database level. + * + * @param name The case-sensitive name of the property to set. + */ + void deleteProperty(in AUTF8String name); + + /** + * Whether this card supports vCard properties. Currently only AddrBookCard + * supports vCard properties. + */ + readonly attribute boolean supportsVCard; + + /** + * A `VCardProperties` object for this card, or null. If `supportsVCard` is + * true, this attribute MUST be a `VCardProperties` object, otherwise it + * MUST be null. + * + * @see VCardProperties in VCardUtils.jsm + */ + readonly attribute jsval vCardProperties; + + /** + * @{ + * These properties are shorthand for getProperty and setProperty. + */ + attribute AString firstName; + attribute AString lastName; + attribute AString displayName; + attribute AString primaryEmail; + /** @} */ + + /** + * All email addresses associated with this card, in order of preference. + */ + readonly attribute Array emailAddresses; + + /** + * Determines whether or not a card has the supplied email address in either + * of its PrimaryEmail or SecondEmail attributes. + * + * Note: This function is likely to be temporary whilst we work out proper + * APIs for multi-valued attributes in bug 118665. + * + * @param aEmailAddress The email address to attempt to match against. + * @return True if aEmailAddress matches any of the email + * addresses stored in the card. + */ + boolean hasEmailAddress(in AUTF8String aEmailAddress); + + /** + * A URL to a photo for this card, or an empty string if there isn't one. + * This is probably a file: or data: URL but other schemes are possible. + */ + readonly attribute AString photoURL; + + /** + * Translates a card into a specific format. + * The following types are supported: + * - base64xml + * - xml + * - vcard + * + * @param aType The type of item to translate the card into. + * @return A string containing the translated card. + * @exception NS_ERROR_ILLEGAL_VALUE if we do not recognize the type. + */ + AUTF8String translateTo(in AUTF8String aType); + + /** + * Translates a card from the specified format + */ + //void translateFrom(in AUTF8String aType, in AUTF8String aData); + + /** + * Generate a phonetic name from the card, using the firstName and lastName + * values. + * + * @param aLastNameFirst Set to True to put the last name before the first. + * @return A string containing the generated phonetic name. + */ + AString generatePhoneticName(in boolean aLastNameFirst); + + /** + * Generate a chat name from the card, containing the value of the + * first non-empty chat field. + * + * @return A string containing the generated chat name. + */ + AString generateChatName(); + + /** + * This function will copy all values from one card to another. + * + * @param srcCard The source card to copy values from. + */ + void copy(in nsIAbCard aSrcCard); + + /** + * Returns true if this card is equal to the other card. + * + * The default implementation defines equal as this card pointing to the + * same object as @arg aCard; another implementation defines it as equality of + * properties and values. + * + * @warning The exact nature of equality is still undefined, and actual + * results may not match theoretical results. Most notably, the code + * a.equals(b) == b.equals(a) might not return true. In + * particular, calling equals on cards from different address books + * may return inaccurate results. + * + * + * @return Equality, as defined above. + * @param aCard The card to compare against. + */ + boolean equals(in nsIAbCard aCard); + + // PROPERTIES TO BE DELETED AS PART OF REWRITE + + attribute boolean isMailList; + /** + * If isMailList is true then mailListURI + * will contain the URI of the associated + * mail list + */ + attribute string mailListURI; +}; + +%{C++ +// A nice list of properties for the benefit of C++ clients +#define kUIDProperty "UID" +#define kFirstNameProperty "FirstName" +#define kLastNameProperty "LastName" +#define kDisplayNameProperty "DisplayName" +#define kNicknameProperty "NickName" +#define kPriEmailProperty "PrimaryEmail" +#define kLastModifiedDateProperty "LastModifiedDate" +#define kPopularityIndexProperty "PopularityIndex" + +#define kPhoneticFirstNameProperty "PhoneticFirstName" +#define kPhoneticLastNameProperty "PhoneticLastName" +#define kSpouseNameProperty "SpouseName" +#define kFamilyNameProperty "FamilyName" +#define k2ndEmailProperty "SecondEmail" + +#define kHomeAddressProperty "HomeAddress" +#define kHomeAddress2Property "HomeAddress2" +#define kHomeCityProperty "HomeCity" +#define kHomeStateProperty "HomeState" +#define kHomeZipCodeProperty "HomeZipCode" +#define kHomeCountryProperty "HomeCountry" +#define kHomeWebPageProperty "WebPage2" + +#define kWorkAddressProperty "WorkAddress" +#define kWorkAddress2Property "WorkAddress2" +#define kWorkCityProperty "WorkCity" +#define kWorkStateProperty "WorkState" +#define kWorkZipCodeProperty "WorkZipCode" +#define kWorkCountryProperty "WorkCountry" +#define kWorkWebPageProperty "WebPage1" + +#define kHomePhoneProperty "HomePhone" +#define kHomePhoneTypeProperty "HomePhoneType" +#define kWorkPhoneProperty "WorkPhone" +#define kWorkPhoneTypeProperty "WorkPhoneType" +#define kFaxProperty "FaxNumber" +#define kFaxTypeProperty "FaxNumberType" +#define kPagerTypeProperty "PagerNumberType" +#define kPagerProperty "PagerNumber" +#define kCellularProperty "CellularNumber" +#define kCellularTypeProperty "CellularNumberType" + +#define kJobTitleProperty "JobTitle" +#define kDepartmentProperty "Department" +#define kCompanyProperty "Company" +#define kScreenNameProperty "_AimScreenName" +#define kCustom1Property "Custom1" +#define kCustom2Property "Custom2" +#define kCustom3Property "Custom3" +#define kCustom4Property "Custom4" +#define kNotesProperty "Notes" + +#define kGtalkProperty "_GoogleTalk" +#define kAIMProperty "_AimScreenName" +#define kYahooProperty "_Yahoo" +#define kSkypeProperty "_Skype" +#define kQQProperty "_QQ" +#define kMSNProperty "_MSN" +#define kICQProperty "_ICQ" +#define kXMPPProperty "_JabberId" +#define kIRCProperty "_IRC" + +#define kAnniversaryYearProperty "AnniversaryYear" +#define kAnniversaryMonthProperty "AnniversaryMonth" +#define kAnniversaryDayProperty "AnniversaryDay" +#define kBirthYearProperty "BirthYear" +#define kBirthMonthProperty "BirthMonth" +#define kBirthDayProperty "BirthDay" +%} diff --git a/comm/mailnews/addrbook/public/nsIAbDirSearchListener.idl b/comm/mailnews/addrbook/public/nsIAbDirSearchListener.idl new file mode 100644 index 0000000000..cc78f1137f --- /dev/null +++ b/comm/mailnews/addrbook/public/nsIAbDirSearchListener.idl @@ -0,0 +1,40 @@ +/* -*- 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/. */ + +#include "nsISupports.idl" + +interface nsIAbCard; +interface nsITransportSecurityInfo; + +/** + * Listener callbacks for addressbook nsIAbDirectory searches and queries. + */ +[scriptable, uuid(eafe2488-4efb-4ac8-a6b4-7756eb1650a3)] +interface nsIAbDirSearchListener : nsISupports { + /** + * Invoked for each matching result found by the search. + * + * @param aCard A matching addressbook card. + */ + void onSearchFoundCard(in nsIAbCard aCard); + + /** + * Invoked when the search finishes. + * + * @param status The result of the search. NS_OK means the search + * completed without error. NS_ERROR_ABORT means the user + * stopped the search. But there are many other error codes + * which may be seen here (LDAP or NSS errors, for example). + * @param complete Whether this search returned all possible results. + * @param secInfo If status is an NSS error code, the securityInfo of the + * failing operation is passed out here. This can be used + * to obtain a failing certificate, to present the user an + * option to add it as a security exception (handy for + * LDAP servers with self-signed certs). + * @param location If status is an NSS error code, this holds the location + * of the failed operation (":"). + */ + void onSearchFinished(in nsresult status, in bool complete, in nsITransportSecurityInfo secInfo, in ACString location); +}; diff --git a/comm/mailnews/addrbook/public/nsIAbDirectory.idl b/comm/mailnews/addrbook/public/nsIAbDirectory.idl new file mode 100644 index 0000000000..07eab7aa81 --- /dev/null +++ b/comm/mailnews/addrbook/public/nsIAbDirectory.idl @@ -0,0 +1,371 @@ +/* -*- 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/. */ + +#include "nsISupports.idl" + +interface nsIAbCard; +interface nsIAbDirSearchListener; + +/* moz-abdirectory:// is the URI to access nsAbBSDirectory, + * which is the root directory for all types of address books + * this is used to get all address book directories. */ + +%{C++ +#define kAllDirectoryRoot "moz-abdirectory://" + +#define kPersonalAddressbook "abook.sqlite" +#define kPersonalAddressbookUri "jsaddrbook://abook.sqlite" +#define kCollectedAddressbook "history.sqlite" +#define kCollectedAddressbookUri "jsaddrbook://history.sqlite" + +#define kABFileName_PreviousSuffix ".na2" /* final v2 address book format */ +#define kABFileName_PreviousSuffixLen 4 +#define kABFileName_CurrentSuffix ".mab" /* v3 address book extension */ + +#define kJSDirectoryRoot "jsaddrbook://" +#define kJSAddressBook "abook.sqlite" +%} + +/** + * A top-level address book directory. + * + * Please note that in order to be properly instantiated by nsIAbManager, every + * type of nsIAbDirectory must have a contract ID of the form: + * + * @mozilla.org/addressbook/directory;1?type= + * + * Where AB URI Scheme does not include the ://. For example, for the + * SQLite-based address book, the scheme is "jsaddrbook", so the contract ID for + * the SQLite-based address book type is: + * + * @mozilla.org/addressbook/directory;1?type=jsaddrbook + */ +[scriptable, uuid(72dc868b-db5b-4daa-b6c6-071be4a05d02)] +interface nsIAbDirectory : nsISupports { + /** + * Returns true if this collection is read-only. + */ + readonly attribute boolean readOnly; + + /** + * Returns true if this collection is accessed over a network connection. + */ + readonly attribute boolean isRemote; + + /** + * Returns true if this collection is accessed over a secure connection. + * + * If isRemote returns false, then this value MUST be false as well. + */ + readonly attribute boolean isSecure; + + /** + * Returns an address book card for the specified email address if found. + * + * If there are multiple cards with the given email address, this method will + * return one of these cards in an implementation-defined manner. + * + * Matching is performed in a case-insensitive manner. + * + * This method performs a synchronous operation. If the collection cannot do + * the search in such a manner, then it should throw NS_ERROR_NOT_IMPLEMENTED. + * + * @param emailAddress The email address to find in any of the email address + * fields. If emailAddress is empty, the database won't + * be searched and the function will return as if no card + * was found. + * @return An nsIAbCard if one was found, else returns NULL. + * @exception NS_ERROR_NOT_IMPLEMENTED If the collection cannot do this. + */ + nsIAbCard cardForEmailAddress(in AUTF8String emailAddress); + + /** + * Returns an address book card for the specified property if found. + * + * If there are multiple cards with the given value for the property, this + * method will return one of these cards in an implementation-defined manner. + * + * This method performs a synchronous operation. If the collection cannot do + * the search in such a manner, then it should throw NS_ERROR_NOT_IMPLEMENTED. + * + * If the property is not natively a string, it can still be searched for + * using the string-encoded value of the property, e.g. "0". See + * nsIAbCard::getPropertyAsAUTF8String for more information. Empty values will + * return no match, to prevent spurious results. + * + * @param aProperty The property to look for. + * @param aValue The value to search for. + * @param aCaseSensitive True if matching should be done case-sensitively. + * @result An nsIAbCard if one was found, else returns NULL. + * @exception NS_ERROR_NOT_IMPLEMENTED If the collection cannot do this. + */ + nsIAbCard getCardFromProperty(in string aProperty, in AUTF8String aValue, + in boolean aCaseSensitive); + + /** + * Returns all address book cards with a specific property matching value + * + * This function is almost identical to getCardFromProperty, with the + * exception of returning all cards rather than just the first. + * + * @param aProperty The property to look for. + * @param aValue The value to search for. + * @param aCaseSensitive True if matching should be done case-sensitively. + * @result The matching nsIAbCard instances. + */ + Array getCardsFromProperty(in string aProperty, + in AUTF8String aValue, + in boolean aCaseSensitive); + + /** + * Returns the nsIAbDirectory for a mailing list with the specified name. + */ + nsIAbDirectory getMailListFromName(in AString aName); + + /** + * The chrome URI to use for bringing up a dialog to edit this directory. + * When opening the dialog, use a JS argument of + * {selectedDirectory: thisdir} where thisdir is this directory that you just + * got the chrome URI from. + */ + readonly attribute ACString propertiesChromeURI; + + /** + * The description of the directory. If this directory is not a mailing list, + * then setting this attribute will send round a "DirName" update via + * nsIAddrBookSession. + */ + attribute AString dirName; + + // XXX This should really be replaced by a QI or something better + readonly attribute long dirType; + + // The filename for address books within this directory. + readonly attribute ACString fileName; + + /** + * A 128-bit unique identifier for this directory. + */ + readonly attribute AUTF8String UID; + [noscript] void setUID(in AUTF8String aUID); + + // The URI of the address book + readonly attribute ACString URI; + + // The position of the directory on the display. + readonly attribute long position; + + // will be used for LDAP replication + attribute unsigned long lastModifiedDate; + + // Defines whether this directory is a mail + // list or not + attribute boolean isMailList; + + // Get the children directories + readonly attribute Array childNodes; + + /** + * Get the count of cards associated with the directory. This includes the + * cards associated with the mailing lists too. + */ + readonly attribute unsigned long childCardCount; + + /** + * Get the cards associated with the directory. This will return the cards + * associated with the mailing lists too. + */ + readonly attribute Array childCards; + + /** + * Searches the directory for cards matching query. + * + * The query takes the form: + * (BOOL1(FIELD1,OP1,VALUE1)..(FIELDn,OPn,VALUEn)(BOOL2(FIELD1,OP1,VALUE1)...)...) + * + * BOOLn A boolean operator joining subsequent terms delimited by (). + * For possible values see CreateBooleanExpression(). + * FIELDn An addressbook card data field. + * OPn An operator for the search term. + * For possible values see CreateBooleanConditionString(). + * VALUEn The value to be matched in the FIELDn via the OPn operator. + * The value must be URL encoded by the caller, if it contains any + * special characters including '(' and ')'. + */ + void search(in AString query, in AString searchString, in nsIAbDirSearchListener listener); + + /** + * Initializes a directory, pointing to a particular URI. + */ + void init(in string aURI); + + /** + * Clean up any database connections or open file handles. + * Called at shutdown or if the directory is about to be deleted. + */ + [implicit_jscontext] + Promise cleanUp(); + + // Deletes either a mailing list or a top + // level directory, which also updates the + // preferences + void deleteDirectory(in nsIAbDirectory directory); + + // Check if directory contains card + // If the implementation is asynchronous the card + // may not yet have arrived. If it is in the process + // of obtaining cards the method will throw an + // NS_ERROR_NOT_AVAILABLE exception if the card + // cannot be found. + boolean hasCard(in nsIAbCard cards); + + // Check if directory contains directory + boolean hasDirectory(in nsIAbDirectory dir); + + // Check if directory contains a mailinglist by name + boolean hasMailListWithName(in AString aName); + + /** + * Adds a card to the database. + * + * This card does not need to be of the same type as the database, e.g., one + * can add an nsIAbLDAPCard to an nsIAbMDBDirectory. + * + * @return "Real" card (eg nsIAbLDAPCard) that can be used for some + * extra functions. + */ + nsIAbCard addCard(in nsIAbCard card); + + /** + * Modifies a card in the database to match that supplied. + */ + void modifyCard(in nsIAbCard modifiedCard); + + /** + * Deletes the array of cards from the database. + * + * @param aCards The cards to delete from the database. + */ + void deleteCards(in Array aCards); + + void dropCard(in nsIAbCard card, in boolean needToCopyCard); + + /** + * Whether or not the directory should be searched when doing autocomplete, + * (currently by using GetChildCards); LDAP does not support this in online + * mode, so that should return false; additionally any other directory types + * that also do not support GetChildCards should return false. + * + * @param aIdentity An optional parameter detailing the identity key (see + * nsIMsgAccountManager) that this autocomplete is being + * run against. + * @return True if this directory should/can be used during + * local autocomplete. + */ + boolean useForAutocomplete(in ACString aIdentityKey); + + /** + * Does this directory support mailing lists? Note that in the case + * this directory is a mailing list and nested mailing lists are not + * supported, this will return false rather than true which the parent + * directory might. + */ + readonly attribute boolean supportsMailingLists; + + // Specific to a directory which stores mail lists + + /** + * Creates a new mailing list in the directory. Currently only supported + * for top-level directories. + * + * @param list The new mailing list to add. + * @return The mailing list directory added, which may have been modified. + */ + nsIAbDirectory addMailList(in nsIAbDirectory list); + + /** + * Nick Name of the mailing list. This attribute is only really used when + * the nsIAbDirectory represents a mailing list. + */ + attribute AString listNickName; + + /** + * Description of the mailing list. This attribute is only really used when + * the nsIAbDirectory represents a mailing list. + */ + attribute AString description; + + /** + * Edits an existing mailing list (specified as listCard) into its parent + * directory. You should call this function on the resource with the same + * uri as the listCard. + * + * @param listCard A nsIAbCard version of the mailing list with the new + * values. + */ + void editMailListToDatabase(in nsIAbCard listCard); + + // Copies mail list properties from the srcList + void copyMailList(in nsIAbDirectory srcList); + + /** + * The id of the directory used in prefs e.g. "ldap_2.servers.pab" + */ + readonly attribute ACString dirPrefId; + + /** + * @name getXXXValue + * + * Helper functions to get different types of pref, but return a default + * value if a pref value was not obtained. + * + * @param aName The name of the pref within the branch dirPrefId to + * get a value from. + * + * @param aDefaultValue The default value to return if getting the pref fails + * or the pref is not present. + * + * @return The value of the pref or the default value. + * + * @exception NS_ERROR_NOT_INITIALIZED if the pref branch couldn't + * be obtained (e.g. dirPrefId isn't set). + */ + //@{ + long getIntValue(in string aName, in long aDefaultValue); + boolean getBoolValue(in string aName, in boolean aDefaultValue); + ACString getStringValue(in string aName, in ACString aDefaultValue); + AUTF8String getLocalizedStringValue(in string aName, in AUTF8String aDefaultValue); + //@} + + /** + * The following attributes are read from an nsIAbDirectory via the above methods: + * + * HidesRecipients (Boolean) + * If true, and this nsIAbDirectory is a mailing list, then when sending mail to + * this list, recipients addresses will be hidden from one another by sending + * via BCC. + */ + + /** + * @name setXXXValue + * + * Helper functions to set different types of pref values. + * + * @param aName The name of the pref within the branch dirPrefId to + * get a value from. + * + * @param aValue The value to set the pref to. + * + * @exception NS_ERROR_NOT_INITIALIZED if the pref branch couldn't + * be obtained (e.g. dirPrefId isn't set). + */ + //@{ + void setIntValue(in string aName, in long aValue); + void setBoolValue(in string aName, in boolean aValue); + void setStringValue(in string aName, in ACString aValue); + void setLocalizedStringValue(in string aName, in AUTF8String aValue); + //@} + +}; diff --git a/comm/mailnews/addrbook/public/nsIAbDirectoryQuery.idl b/comm/mailnews/addrbook/public/nsIAbDirectoryQuery.idl new file mode 100644 index 0000000000..e21bca5c05 --- /dev/null +++ b/comm/mailnews/addrbook/public/nsIAbDirectoryQuery.idl @@ -0,0 +1,133 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* 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/. */ + + +#include "nsISupports.idl" + +interface nsIAbDirSearchListener; +interface nsIAbCard; +interface nsIAbDirectory; + +/** + * The arguments for a query. + * + * Contains an expression for perform matches + * and an array of properties which should be + * returned if a match is found from the expression + * + */ +[scriptable, uuid(03af3018-2590-4f4c-a88c-1fff6595ef05)] +interface nsIAbDirectoryQueryArguments : nsISupports +{ + /** + * Defines the boolean expression for + * the matching of cards + * + */ + attribute nsISupports expression; + + /** + * Defines if sub directories should be + * queried + * + */ + attribute boolean querySubDirectories; + + /** + * A parameter which can be used to pass in data specific to a particular + * type of addressbook. + */ + attribute nsISupports typeSpecificArg; + + /** + * A custom search filter which user wants to use in LDAP query. + */ + attribute AUTF8String filter; +}; + + +[scriptable, uuid(3A6E0C0C-1DD2-11B2-B23D-EA3A8CCB333C)] +interface nsIAbDirectoryQueryPropertyValue : nsISupports +{ + /** + * The property which should be matched + * + * For example 'primaryEmail' or 'homePhone' + * for card properties. + * + * Two further properties are defined that + * do not exist as properties on a card. + * + * 'card:nsIAbCard' which represents the interface + * of a card component + * + */ + readonly attribute string name; + + /** + * The value of the property + * + */ + readonly attribute wstring value; + + /** + * The value of the property + * as an interface + * + * Only valid if the corresponding + * property name is related to an + * interface instead of a wstring + * + */ + readonly attribute nsISupports valueISupports; +}; + +[scriptable, uuid(60b5961c-ce61-47b3-aa99-6d865f734dee)] +interface nsIAbDirectoryQuery : nsISupports +{ + /** + * Initiates a query on a directory and sub-directories for properties + * on cards + * + * @param aDirectory A directory that the query may get extra details + * from. + * + * @param aArguments The properties and values to match value could of + * type nsIAbDirectoryQueryMatchItem for matches other + * than ?contains? + * + * @param aListener The listener which will obtain individual query + * results. + * + * @param aResultLimit Limits the number of results returned to a maximum + * value. + * + * @param aTimeOut The maximum length of time for the query + * + * @return A context id for the query + */ + long doQuery(in nsIAbDirectory aDirectory, + in nsIAbDirectoryQueryArguments aArguments, + in nsIAbDirSearchListener aListener, + in long aResultLimit, + in long aTimeOut); + + /** + * Stops an existing query operation if + * query operation is asynchronous + * + * The nsIAbDirSearchListener will + * be notified when query has stopped + * + * It is implementation specific if notification + * synchronous or asynchronous + * + * @param contextID + * The unique number returned from + * the doQuery methods + * + */ + void stopQuery(in long contextID); +}; diff --git a/comm/mailnews/addrbook/public/nsIAbDirectoryQueryProxy.idl b/comm/mailnews/addrbook/public/nsIAbDirectoryQueryProxy.idl new file mode 100644 index 0000000000..ced61ff8f4 --- /dev/null +++ b/comm/mailnews/addrbook/public/nsIAbDirectoryQueryProxy.idl @@ -0,0 +1,13 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* 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/. */ + + +#include "nsIAbDirectoryQuery.idl" + +[scriptable, uuid(b8034849-1e98-4d39-819c-15ba61a7434f)] +interface nsIAbDirectoryQueryProxy : nsIAbDirectoryQuery +{ + void initiate(); +}; diff --git a/comm/mailnews/addrbook/public/nsIAbLDAPAttributeMap.idl b/comm/mailnews/addrbook/public/nsIAbLDAPAttributeMap.idl new file mode 100644 index 0000000000..c5bf6c565c --- /dev/null +++ b/comm/mailnews/addrbook/public/nsIAbLDAPAttributeMap.idl @@ -0,0 +1,192 @@ +/* -*- Mode: C++; tab-width: 20; 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/. */ + +#include "nsISupports.idl" + +interface nsILDAPMessage; +interface nsIAbCard; + +/** + * A mapping between addressbook properties and ldap attributes. + * + * Each addressbook property can map to one or more attributes. If + * there is no entry in preferences for a field, the getters generally + * return null; empty strings are passed through as usual. The intent is + * that properties with a non-zero number of attributes can be overridden for + * a specific server by supplying a zero-length string. For this to work, + * most callers are likely to want to check for both success and a + * non-empty string. + * + * Note that the one exception to this pattern is getAttributes, which + * throws NS_ERROR_FAILURE for non-existent property entries, since + * XPConnect doesn't like returning null arrays. + * + * Note that each LDAP attribute can map to at most one addressbook + * property. The checkState method is a useful tool in enforcing + * this. Failure to enforce it may make it impossible to guarantee + * that getProperty will do something consistent and reasonable. + * + * Maybe someday once we support ldap autoconfig stuff (ie + * draft-joslin-config-schema-11.txt), we can simplify this and other + * code and only allow a property to map to a single attribute. + */ +[scriptable, uuid(fa019fd1-7f3d-417a-8957-154cca0240be)] +interface nsIAbLDAPAttributeMap : nsISupports +{ + /** + * Get all the LDAP attributes associated with a given property + * name, in order of precedence (highest to lowest). + * + * @param aProperty the address book property to return attrs for + * + * @return a comma-separated list of attributes, null if no entry is + * present + */ + ACString getAttributeList(in ACString aProperty); + + /** + * Get all the LDAP attributes associated with a given property name, in + * order of precedence (highest to lowest). + * + * @param aProperty the address book property to return attrs for + * + * @return an array of attributes + * + * @exception NS_ERROR_FAILURE if there is no entry for this property + */ + Array getAttributes(in ACString aProperty); + + /** + * Get the first (canonical) LDAP attribute associated with a given property + * name + * + * @param aProperty the address book property to return attrs for + * + * @return the first attribute associated with a given property, + * null if there is no entry for this property + */ + ACString getFirstAttribute(in ACString aProperty); + + /** + * Set an existing mapping to the comma-separated list of attributes. + * + * @param aProperty the mozilla addressbook property name + * + * @param aAttributeList a comma-separated list of attributes in + * order of precedence from high to low + * + * @param aAllowInconsistencies allow changes that would result in + * a map with an LDAP attribute associated + * with more than one property. Useful for + * doing a bunch of sets at once, and + * calling checkState at the end. + * + * @exception NS_ERROR_FAILURE making this change would result in a map + * with an LDAP attribute pointing to more + * than one property + */ + void setAttributeList(in ACString aProperty, in ACString aAttributeList, + in boolean allowInconsistencies); + + /** + * Find the Mozilla addressbook property name that this attribute should + * map to. + * + * @return the addressbook property name, null if it's not used in the map + */ + ACString getProperty(in ACString aAttribute); + + /** + * Get all attributes that may be used in an addressbook card via this + * property map (used for passing to to an LDAP search when you want + * everything that could be in a card returned). + * + * @return a comma-separated list of attribute names + * + * @exception NS_ERROR_FAILURE there are no attributes in this property map + */ + ACString getAllCardAttributes(); + + /** + * Get all properties that may be used in an addressbook card via this + * property map. + * + * @return an array of properties + * + * @exception NS_ERROR_FAILURE there are no attributes in this property map + */ + Array getAllCardProperties(); + + /** + * Check that no LDAP attributes are listed in more than one property. + * + * @exception NS_ERROR_FAILURE one or more LDAP attributes are listed + * multiple times. The object is now in an + * inconsistent state, and should be either + * manually repaired or discarded. + */ + void checkState(); + + /* These last two methods are really just for the convenience of the caller + * and to avoid tons of unnecessary crossing of the XPConnect boundary. + */ + + /** + * Set any attributes specified in the given prefbranch on this object. + * + * @param aPrefBranchName the pref branch containing all the + * property names + * + * @exception NS_ERROR_FAILURE one or more LDAP attributes are listed + * multiple times. The object is now in an + * inconsistent state, and should be either + * manually repaired or discarded. + */ + void setFromPrefs(in ACString aPrefBranchName); + + /** + * Set the properties on an addressbook card from the given LDAP message + * using the map in this object. + * + * @param aCard is the card object whose values are to be set + * @param aMessage is the LDAP message to get the values from + * + * @exception NS_ERROR_FAILURE is thrown if no addressbook properties + * are found in the message + */ + void setCardPropertiesFromLDAPMessage(in nsILDAPMessage aMessage, + in nsIAbCard aCard); +}; + +/** + * The nsIAbLDAPAttributeMapService is used to build and hold a cache + * of maps. + */ +[scriptable, uuid(12e2d589-3c2a-48e4-8c82-b1e6464a0dfd)] +interface nsIAbLDAPAttributeMapService : nsISupports +{ + /** + * Accessor to construct or return a cached copy of the attribute + * map for a given preference branch. The map is constructed by + * first taking the default map (as specified by the + * "ldap_2.servers.default.attrmap" prefbranch), and then having any + * preferences specified by aPrefBranchName override the defaults. + * LDIF import and export code should use the default map. + * + * @return the requested map + * + * @exception NS_ERROR_FAILURE error constructing the map; + * possibly because of a failure + * from checkState() + */ + nsIAbLDAPAttributeMap getMapForPrefBranch(in ACString aPrefBranchName); +}; + + +%{C++ +// test whether one of the getters has actually found an attribute +#define ATTRMAP_FOUND_ATTR(rv, str) (NS_SUCCEEDED(rv) && !(str).IsEmpty()) +%} diff --git a/comm/mailnews/addrbook/public/nsIAbLDAPDirectory.idl b/comm/mailnews/addrbook/public/nsIAbLDAPDirectory.idl new file mode 100644 index 0000000000..8d84bf688e --- /dev/null +++ b/comm/mailnews/addrbook/public/nsIAbLDAPDirectory.idl @@ -0,0 +1,97 @@ +/* -*- 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/. */ + +#include "nsISupports.idl" + +interface nsIFile; +interface nsIAbLDAPAttributeMap; +interface nsILDAPURL; + +%{C++ +#define kLDAPDirectoryRoot "moz-abldapdirectory://" +#define kLDAPDirectoryRootLen 22 +%} + +/** + * XXX This should really inherit from nsIAbDirectory, and some day it will. + * But for now, doing that complicates implementation. + */ +[scriptable, uuid(90dde295-e354-4d58-Add8-f9b29a95942d)] +interface nsIAbLDAPDirectory : nsISupports +{ + /** + * The Replication File Name to use. + */ + attribute ACString replicationFileName; + + /** + * The version of LDAP protocol in use. + */ + attribute unsigned long protocolVersion; + + /** + * The SASL mechanism to use to authenticate to the LDAP server + * If this is an empty string, then a simple bind will be performed + * A non-zero string is assumed to be the name of the SASL mechanism. + * Currently the only supported mechanism is GSSAPI + */ + attribute ACString saslMechanism; + + /** + * The AuthDN to use to access the server. + */ + attribute AUTF8String authDn; + + /** + * The maximum number of matches that the server will return per a search. + */ + attribute long maxHits; + + /** + * The Last Change Number used for replication. + */ + attribute long lastChangeNumber; + + /** + * The LDAP server's scoping of the lastChangeNumber. + */ + attribute ACString dataVersion; + + /** + * The attribute map that is associated with this directory's server. + */ + readonly attribute nsIAbLDAPAttributeMap attributeMap; + + /** + * The LDAP URL for this directory. Note that this differs from + * nsIAbDirectory::URI. This attribute will give you a true ldap + * url, e.g. ldap://localhost:389/ whereas the uri will give you the + * directories rdf uri, e.g. moz-abldapdirectory:///. + */ + attribute nsILDAPURL lDAPURL; + + /** + * The replication (offline) file that this database uses. + */ + readonly attribute nsIFile replicationFile; + + /** + * The LDAP attributes used to build the Relative Distinguished Name + * of new cards, in the form of a comma separated list. + * + * The default is to use the common name (cn) attribute. + */ + attribute ACString rdnAttributes; + + /** + * The LDAP objectClass values added to cards when they are created/added, + * in the form of a comma separated list. + * + * The default is to use the following classes: + * top,person,organizationalPerson,inetOrgPerson,mozillaAbPersonAlpha + */ + attribute ACString objectClasses; + +}; diff --git a/comm/mailnews/addrbook/public/nsIAbLDAPReplicationData.idl b/comm/mailnews/addrbook/public/nsIAbLDAPReplicationData.idl new file mode 100644 index 0000000000..c42ffc9f4d --- /dev/null +++ b/comm/mailnews/addrbook/public/nsIAbLDAPReplicationData.idl @@ -0,0 +1,54 @@ +/* -*- 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/. */ + +#include "nsISupports.idl" + +interface nsIAbLDAPDirectory; +interface nsILDAPConnection; +interface nsILDAPURL; +interface nsIAbLDAPReplicationQuery; +interface nsIWebProgressListener; + +/** + * this service does replication of an LDAP directory to a local AB Database. + */ +[scriptable, uuid(e628bbc9-8793-4f0b-bce4-990d399b1fca)] +interface nsIAbLDAPProcessReplicationData : nsISupports +{ + /** + * readonly attribute giving the current replication state + */ + readonly attribute int32_t replicationState; + + /** + * replication states + */ + const long kIdle = 0; + const long kAnonymousBinding = 1; + const long kAuthenticatedBinding = 2; + const long kSyncServerBinding = 3; + const long kSearchingAuthDN = 4; + const long kDecidingProtocol = 5; + const long kAuthenticating = 6; + const long kReplicatingAll = 7; + const long kSearchingRootDSE = 8; + const long kFindingChanges = 9; + const long kReplicatingChanges = 10; + const long kReplicationDone = 11; + + /** + * this method initializes the implementation + */ + void init(in nsIAbLDAPDirectory directory, + in nsILDAPConnection connection, + in nsILDAPURL url, + in nsIAbLDAPReplicationQuery query, + in nsIWebProgressListener progressListener); + + /** + * this method a aborts the ongoing processing + */ + void abort(); +}; diff --git a/comm/mailnews/addrbook/public/nsIAbLDAPReplicationQuery.idl b/comm/mailnews/addrbook/public/nsIAbLDAPReplicationQuery.idl new file mode 100644 index 0000000000..aa9db9ab61 --- /dev/null +++ b/comm/mailnews/addrbook/public/nsIAbLDAPReplicationQuery.idl @@ -0,0 +1,63 @@ +/* -*- 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/. */ + +#include "nsISupports.idl" + +interface nsIWebProgressListener; +interface nsIAbLDAPDirectory; + +/** + * this interface provides methods to perform LDAP Replication Queries + */ +[scriptable, uuid(460a739c-a8c1-4f24-b705-c89d136ab9f5)] +interface nsIAbLDAPReplicationQuery : nsISupports +{ + /** + * initialize for the query + */ + void init(in nsIAbLDAPDirectory aDirectory, + in nsIWebProgressListener aProgressListener); + + /** + * Starts an LDAP query to do replication as needed + */ + void doReplicationQuery(); + + /** + * Cancels the currently executing query + */ + void cancelQuery(); + + /** + * this method is the callback when query is done, failed or successful + */ + void done(in boolean aSuccess); +}; + +// XXX This interface currently isn't implemented as it didn't work. +// Bug 311632 should fix it +[scriptable, uuid(126202D1-4460-11d6-B7C2-00B0D06E5F27)] +interface nsIAbLDAPChangeLogQuery : nsISupports +{ + /** + * Starts an LDAP query to find auth DN + */ + void queryAuthDN(in AUTF8String aValueUsedToFindDn); + + /** + * Starts an LDAP query to search server's Root DSE + */ + void queryRootDSE(); + + /** + * Starts an LDAP ChangeLog query to find changelog entries + */ + void queryChangeLog(in AUTF8String aChangeLogDN, in int32_t aLastChangeNo); + + /** + * Starts an LDAP query to find changed entries + */ + void queryChangedEntries(in AUTF8String aChangedEntryDN); +}; diff --git a/comm/mailnews/addrbook/public/nsIAbLDAPReplicationService.idl b/comm/mailnews/addrbook/public/nsIAbLDAPReplicationService.idl new file mode 100644 index 0000000000..010c73d956 --- /dev/null +++ b/comm/mailnews/addrbook/public/nsIAbLDAPReplicationService.idl @@ -0,0 +1,31 @@ +/* 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/. */ + +#include "nsISupports.idl" + +interface nsIWebProgressListener; +interface nsIAbLDAPDirectory; + +/** + * this service does replication of an LDAP directory to a local AB Database. + */ +[scriptable, uuid(3f499c70-5ceb-4b91-8b7f-62c366859383)] +interface nsIAbLDAPReplicationService: nsISupports { + + /** + * Start Replication of given LDAP directory represented by the URI + */ + void startReplication(in nsIAbLDAPDirectory aDirectory, + in nsIWebProgressListener progressListener); + + /** + * Cancel Replication of given LDAP directory represented by the URI + */ + void cancelReplication(in nsIAbLDAPDirectory aDirectory); + + /** + * callback when replication is done, failure or success + */ + void done(in boolean aSuccess); +}; diff --git a/comm/mailnews/addrbook/public/nsIAbLDIFService.idl b/comm/mailnews/addrbook/public/nsIAbLDIFService.idl new file mode 100644 index 0000000000..6a32c458da --- /dev/null +++ b/comm/mailnews/addrbook/public/nsIAbLDIFService.idl @@ -0,0 +1,43 @@ +/* -*- 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/. */ +#include "nsISupports.idl" + +interface nsIFile; +interface nsIAbDirectory; + +[scriptable, uuid(7afaa95f-0b1c-4d8a-a65f-bb5073ed6d39)] +interface nsIAbLDIFService : nsISupports { + + /** + * Determine if a file is likely to be an LDIF file based on field + * names that commonly appear in LDIF files. + * + * @param aSrc The file to examine + * + * @return true if the file appears to be of LDIF type, + * false otherwise + */ + boolean isLDIFFile(in nsIFile aSrc); + + /** + * Imports a file into the specified address book. + * + * @param aDirectory The address book to import addresses into. + * + * @param aSrc The file to import addresses from. + * + * @param aStoreLocAsHome Stores the address as a home rather than work + * address. + * + * @param aProgress May be null, but if a pointer is supplied, + * then it will be updated regularly with the + * current position of reading from the file. + * + */ + void importLDIFFile(in nsIAbDirectory aDirectory, + in nsIFile aSrc, + in boolean aStoreLocAsHome, + inout unsigned long aProgress); +}; diff --git a/comm/mailnews/addrbook/public/nsIAbManager.idl b/comm/mailnews/addrbook/public/nsIAbManager.idl new file mode 100644 index 0000000000..366866d05b --- /dev/null +++ b/comm/mailnews/addrbook/public/nsIAbManager.idl @@ -0,0 +1,132 @@ +/* -*- Mode: IDL; 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/. */ + +#include "nsISupports.idl" + +interface mozIDOMWindowProxy; +interface nsIAbDirectory; +interface nsIAbCard; +interface nsIFile; +interface nsIAbBooleanExpression; + +/** + * nsIAbManager is an interface to the main address book manager + * via the contract id "@mozilla.org/abmanager;1" + * + * It contains the main functions to create and delete address books as well + * as some helper functions. + */ +[scriptable, uuid(ea0d8b3d-a549-4874-82d8-3a82cee2a3f1)] +interface nsIAbManager : nsISupports +{ + const unsigned long LDAP_DIRECTORY_TYPE = 0; + const unsigned long MAPI_DIRECTORY_TYPE = 3; + const unsigned long JS_DIRECTORY_TYPE = 101; + const unsigned long CARDDAV_DIRECTORY_TYPE = 102; + const unsigned long ASYNC_DIRECTORY_TYPE = 103; + + /** + * Returns an array containing all the top-level directories. + */ + readonly attribute Array directories; + + /** + * Returns the directory that represents the supplied URI. + * + * @param aURI The URI of the address book to find. + * @return The found address book. + */ + nsIAbDirectory getDirectory(in ACString aURI); + + /** + * Returns the directory that has the supplied dirPrefId. + * + * @param aDirPrefId The dirPrefId of the directory. + * @return The found AB directory. + */ + nsIAbDirectory getDirectoryFromId(in ACString aDirPrefId); + + /** + * Returns the directory that has the supplied UID. + * + * @param aUID The UID of the directory. + * @return The found AB directory. + */ + nsIAbDirectory getDirectoryFromUID(in ACString aUID); + + /** + * Creates a new address book. + * + * @param aDirName The description of the address book. + * @param aURI The URI for the address book. This is specific to each + * type of address book. + * @param aType One of the *_DIRECTORY_TYPE constants. + * @param aUID Sets the UID of the new Address Book. + */ + ACString newAddressBook(in AString aDirName, in ACString aURI, + in unsigned long aType, + [optional] in AUTF8String aUID); + + /** + * Adds a previously created address book object. If it has not been removed + * (using `deleteAddressBook`) it will be removed at the end of the session. + * + * @param aDir The address book object. + */ + void addAddressBook(in nsIAbDirectory aDir); + + /** + * Deletes an address book. + * + * @param aURI The URI for the address book. This is specific to each + * type of address book. + */ + void deleteAddressBook(in ACString aURI); + + /** + * Finds out if the mailing list name exists in any address book. + * + * @param aName The name of the list to try and find. + * + * @return True if the name exists. + */ + boolean mailListNameExists(in AString name); + + /** + * Finds out if the directory name already exists. + * + * @param aName The name of a directory to check for. + * + * @return True if a directory called name already exists. + */ + boolean directoryNameExists(in AString name); + + /** + * Returns an address book card for the specified email address if found, in + * any directory. The first matching card found is returned. + * + * *** Results of this function are cached! *** + * This function is for where speed is more important than accuracy. Results + * are stored in a cache until 60s passes without this function being called. + * The address book *could* change in this time, in a way that produces a + * different result, but probably won't. + * + * @see nsIAbCard.cardForEmailAddress + * @param emailAddress The email address to find in any of the email address + * fields. If emailAddress is empty, the directories + * won't be searched and the function will return as if + * no card was found. + * @return An nsIAbCard if one was found, else returns NULL. + */ + nsIAbCard cardForEmailAddress(in AUTF8String emailAddress); + + /** + * Returns the mailing lists that has the supplied name. + * + * @param aName The name of the list. + * @return The found AB directory. + */ + nsIAbDirectory getMailListFromName(in AString aName); +}; diff --git a/comm/mailnews/addrbook/public/nsIAbOutlookInterface.idl b/comm/mailnews/addrbook/public/nsIAbOutlookInterface.idl new file mode 100644 index 0000000000..5ab66ac095 --- /dev/null +++ b/comm/mailnews/addrbook/public/nsIAbOutlookInterface.idl @@ -0,0 +1,12 @@ +/* -*- Mode: IDL; 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/. */ + +#include "nsISupports.idl" + +[scriptable, uuid(088d3dea-4a6a-41ce-b974-5043d00f1798)] +interface nsIAbOutlookInterface : nsISupports +{ + Array getFolderURIs(in AUTF8String aURI); +}; diff --git a/comm/mailnews/addrbook/public/nsILDAPBERElement.idl b/comm/mailnews/addrbook/public/nsILDAPBERElement.idl new file mode 100644 index 0000000000..087fd1b2d2 --- /dev/null +++ b/comm/mailnews/addrbook/public/nsILDAPBERElement.idl @@ -0,0 +1,122 @@ +/* -*- 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/. */ + +#include "nsISupports.idl" + +interface nsILDAPBERValue; + + +/** + * nsILDAPBERElement is a wrapper interface for a C-SDK BerElement object. + * Typically, this is used as an intermediate object to aid in the manual + * construction of a BER value. Once the construction is completed by calling + * methods on this object, an nsILDAPBERValue can be retrieved from the + * asValue attribute on this interface. + * + * + * contains some documentation that mostly (but not exactly) matches + * the code that this wraps in section 17. + */ + +[scriptable, uuid(409f5b31-c062-4d11-a35b-0a09e7967bf2)] +interface nsILDAPBERElement : nsISupports +{ + /** + * Initialize this object. Must be called before calling any other method + * on this interface. + * + * @param aValue value to preinitialize with; 0 for a new empty object + * + * @exception NS_ERROR_NOT_IMPLEMENTED preinitialization is currently + * not implemented + * @exception NS_ERROR_OUT_OF_MEMORY unable to allocate the internal + * BerElement + */ + void init(in nsILDAPBERValue aValue); + + /** + * Most TAG_* constants can be used in the construction or passing in of + * values to the aTag arguments to most of the methods in this interface. + */ + + /** + * When returned from a parsing method, 0xffffffff is referred to + * has the parse-error semantic (ie TAG_LBER_ERROR); when passing it to + * a construction method, it is used to mean "pick the default tag for + * this type" (ie TAG_LBER_DEFAULT). + */ + const unsigned long TAG_LBER_ERROR = 0xffffffff; + const unsigned long TAG_LBER_DEFAULT = 0xffffffff; + const unsigned long TAG_LBER_END_OF_SEQORSET = 0xfffffffe; + + /** + * BER encoding types and masks + */ + const unsigned long TAG_LBER_PRIMITIVE = 0x00; + + /** + * The following two tags are carried over from the LDAP C SDK; their + * exact purpose there is not well documented. They both have + * the same value there as well. + */ + const unsigned long TAG_LBER_CONSTRUCTED = 0x20; + const unsigned long TAG_LBER_ENCODING_MASK = 0x20; + + const unsigned long TAG_LBER_BIG_TAG_MASK = 0x1f; + const unsigned long TAG_LBER_MORE_TAG_MASK = 0x80; + + /** + * general BER types we know about + */ + const unsigned long TAG_LBER_BOOLEAN = 0x01; + const unsigned long TAG_LBER_INTEGER = 0x02; + const unsigned long TAG_LBER_BITSTRING = 0x03; + const unsigned long TAG_LBER_OCTETSTRING = 0x04; + const unsigned long TAG_LBER_NULL = 0x05; + const unsigned long TAG_LBER_ENUMERATED = 0x0a; + const unsigned long TAG_LBER_SEQUENCE = 0x30; + const unsigned long TAG_LBER_SET = 0x31; + + /** + * Write a string to this element. + * + * @param aString string to write + * @param aTag tag for this string (if TAG_LBER_DEFAULT is used, + * TAG_LBER_OCTETSTRING will be written). + * + * @return number of bytes written + * + * @exception NS_ERROR_FAILUE C-SDK returned error + */ + unsigned long putString(in AUTF8String aString, in unsigned long aTag); + + /** + * Start a set. Sets may be nested. + * + * @param aTag tag for this set (if TAG_LBER_DEFAULT is used, + * TAG_LBER_SET will be written). + * + * @exception NS_ERROR_FAILUE C-SDK returned an error + */ + void startSet(in unsigned long aTag); + + /** + * Cause the entire set started by the last startSet() call to be written. + * + * @exception NS_ERROR_FAILUE C-SDK returned an error + * + * @return number of bytes written + */ + unsigned long putSet(); + + /** + * an nsILDAPBERValue version of this element. Calls ber_flatten() under + * the hood. + * + * @exception NS_ERROR_OUT_OF_MEMORY + */ + readonly attribute nsILDAPBERValue asValue; +}; diff --git a/comm/mailnews/addrbook/public/nsILDAPBERValue.idl b/comm/mailnews/addrbook/public/nsILDAPBERValue.idl new file mode 100644 index 0000000000..e4a5651476 --- /dev/null +++ b/comm/mailnews/addrbook/public/nsILDAPBERValue.idl @@ -0,0 +1,41 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- + * + * 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/. */ + +#include "nsISupports.idl" + +/** + * Representation of a BER value as an interface containing an array of + * bytes. Someday this should perhaps be obsoleted by a better, more + * generalized version of nsIByteBuffer, but that's currently not even + * scriptable (see bug 125596). + */ +[scriptable, uuid(c817c5fe-1dd1-11b2-a10b-ae9885762ea9)] +interface nsILDAPBERValue : nsISupports +{ + /** + * Set the BER value from an array of bytes (copies). + * + * @exception NS_ERROR_OUT_OF_MEMORY couldn't allocate buffer to copy to + */ + void set(in Array aValue); + + /** + * Set the BER value from a UTF8 string (copies). + * + * @exception NS_ERROR_OUT_OF_MEMORY couldn't allocate buffer to copy to + */ + void setFromUTF8(in AUTF8String aValue); + + /** + * Get the BER value as an array of bytes. Note that if this value is + * zero-length, aCount and aRetVal will both be 0. This means that + * (in C++ anyway) the caller MUST test either aCount or aRetval before + * dereferencing aRetVal. + * + * @exception NS_ERROR_OUT_OF_MEMORY couldn't allocate buffer to copy to + */ + Array get(); +}; diff --git a/comm/mailnews/addrbook/public/nsILDAPConnection.idl b/comm/mailnews/addrbook/public/nsILDAPConnection.idl new file mode 100644 index 0000000000..5fb44dd67c --- /dev/null +++ b/comm/mailnews/addrbook/public/nsILDAPConnection.idl @@ -0,0 +1,77 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- + * + * 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/. */ + +#include "nsISupports.idl" + +interface nsILDAPOperation; +interface nsILDAPMessageListener; +interface nsILDAPURL; + +%{C++ +#define NS_LDAPCONNECTION_CONTRACTID "@mozilla.org/network/ldap-connection;1" +%} + +[scriptable, uuid(360c1ff7-15e3-4ffe-b4b8-0eda72ebc096)] +interface nsILDAPConnection : nsISupports +{ + /** + * the string version of lderrno + */ + readonly attribute wstring errorString; + + /** + * DN to bind as. use the init() method to set this. + * + * @exception NS_ERROR_OUT_OF_MEMORY + */ + readonly attribute AUTF8String bindName; + + /** + * private parameter (anything caller desires) + */ + attribute nsISupports closure; + + /** + * Set up the connection. Note that init() must be called on a thread + * that already has an nsIEventQueue. + * + * @param aUrl A URL for the ldap server. The host, port and + * ssl connection type will be extracted from this + * @param aBindName DN to bind as + * @param aMessageListener Callback for DNS resolution completion + * @param aClosure private parameter (anything caller desires) + * @param aVersion LDAP version to use (currently VERSION2 or + * VERSION3) + * + * @exception NS_ERROR_ILLEGAL_VALUE null pointer or invalid version + * @exception NS_ERROR_OUT_OF_MEMORY ran out of memory + * @exception NS_ERROR_OFFLINE we are in off-line mode + * @exception NS_ERROR_FAILURE + * @exception NS_ERROR_UNEXPECTED internal error + */ + void init(in nsILDAPURL aUrl, + in AUTF8String aBindName, + in nsILDAPMessageListener aMessageListener, + in nsISupports aClosure, in unsigned long aVersion); + + const unsigned long VERSION2 = 2; + const unsigned long VERSION3 = 3; + + /** + * Get information about the last error that occurred on this connection. + * + * @param matched if the server is returning LDAP_NO_SUCH_OBJECT, + * LDAP_ALIAS_PROBLEM, LDAP_INVALID_DN_SYNTAX, + * or LDAP_ALIAS_DEREF_PROBLEM, this will contain + * the portion of DN that matches the entry that is + * closest to the requested entry + * + * @param s additional error information from the server + * + * @return the error code, as defined in nsILDAPErrors.idl + */ + long getLdErrno(out AUTF8String matched, out AUTF8String s); +}; diff --git a/comm/mailnews/addrbook/public/nsILDAPControl.idl b/comm/mailnews/addrbook/public/nsILDAPControl.idl new file mode 100644 index 0000000000..97a70a4d93 --- /dev/null +++ b/comm/mailnews/addrbook/public/nsILDAPControl.idl @@ -0,0 +1,45 @@ +/* -*- 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/. */ + +#include "nsISupports.idl" + +interface nsILDAPBERValue; + +/** + * XPCOM representation of the C SDK LDAPControl structure. + */ +[scriptable, uuid(3a7ceb8e-482a-4a4f-9aa4-26b9a69a3595)] +interface nsILDAPControl : nsISupports +{ + /** + * Control type, represented as a string. + * + * @exceptions none + */ + attribute ACString oid; + + /** + * The data associated with a control, if any. To specify that no data + * is to be associated with the control, don't set this at all (which + * is equivalent to setting it to null). + * + * @note Specifying a zero-length value is not currently supported. At some + * date, setting this to an nsILDAPBERValue which has not had any of the + * set methods called will be the appropriate way to do that. + * + * @exceptions none + */ + attribute nsILDAPBERValue value; + + /** + * Should the client or server abort if the control is not understood? + * Should be set to false for server controls used in abandon and unbind + * operations, since those have no server response. + * + * @exceptions none + */ + attribute boolean isCritical; +}; diff --git a/comm/mailnews/addrbook/public/nsILDAPErrors.idl b/comm/mailnews/addrbook/public/nsILDAPErrors.idl new file mode 100644 index 0000000000..0251f63293 --- /dev/null +++ b/comm/mailnews/addrbook/public/nsILDAPErrors.idl @@ -0,0 +1,447 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- + * + * 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/. */ + +#include "nsISupports.idl" + +/** + * Error codes used in the LDAP XPCOM SDK. + * + * Taken from the Mozilla C SDK's ldap.h include file, these should be + * the same as those specified in the draft-ietf-ldapext-ldap-c-api-04.txt + * Internet Draft. + * + * The only good documentation I'm aware of for these error codes is + * at . + * Unfortunately, this does not currently seem to be available under any + * open source license, so I can't include that documentation here as + * doxygen comments. + * + */ +[scriptable, uuid(f9ac10fa-1dd1-11b2-9798-8d5cbda95d74)] +interface nsILDAPErrors : nsISupports +{ + + const long SUCCESS = 0x00; + + const long OPERATIONS_ERROR = 0x01; + + const long PROTOCOL_ERROR = 0x02; + + const long TIMELIMIT_EXCEEDED = 0x03; + + const long SIZELIMIT_EXCEEDED = 0x04; + + const long COMPARE_FALSE = 0x05; + + const long COMPARE_TRUE = 0x06; + + const long STRONG_AUTH_NOT_SUPPORTED = 0x07; + + const long STRONG_AUTH_REQUIRED = 0x08; + + + /** + * UMich LDAPv2 extension + */ + const long PARTIAL_RESULTS = 0x09; + + /** + * new in LDAPv3 + */ + const long REFERRAL = 0x0a; + + /** + * new in LDAPv3 + */ + const long ADMINLIMIT_EXCEEDED = 0x0b; + + /** + * new in LDAPv3 + */ + const long UNAVAILABLE_CRITICAL_EXTENSION = 0x0c; + + /** + * new in LDAPv3 + */ + const long CONFIDENTIALITY_REQUIRED = 0x0d; + + /** + * new in LDAPv3 + */ + const long SASL_BIND_IN_PROGRESS = 0x0e; + + const long NO_SUCH_ATTRIBUTE = 0x10; + + const long UNDEFINED_TYPE = 0x11; + + const long INAPPROPRIATE_MATCHING = 0x12; + + const long CONSTRAINT_VIOLATION = 0x13; + + const long TYPE_OR_VALUE_EXISTS = 0x14; + + const long INVALID_SYNTAX = 0x15; + + const long NO_SUCH_OBJECT = 0x20; + + const long ALIAS_PROBLEM = 0x21; + + const long INVALID_DN_SYNTAX = 0x22; + + /** + * not used in LDAPv3 + */ + const long IS_LEAF = 0x23; + + const long ALIAS_DEREF_PROBLEM = 0x24; + + const long INAPPROPRIATE_AUTH = 0x30; + + const long INVALID_CREDENTIALS = 0x31; + + const long INSUFFICIENT_ACCESS = 0x32; + + const long BUSY = 0x33; + + const long UNAVAILABLE = 0x34; + + const long UNWILLING_TO_PERFORM = 0x35; + + const long LOOP_DETECT = 0x36; + + /** + * server side sort extension + */ + const long SORT_CONTROL_MISSING = 0x3C; + + /** + * VLV extension + */ + const long INDEX_RANGE_ERROR = 0x3D; + + const long NAMING_VIOLATION = 0x40; + + const long OBJECT_CLASS_VIOLATION = 0x41; + + const long NOT_ALLOWED_ON_NONLEAF = 0x42; + + const long NOT_ALLOWED_ON_RDN = 0x43; + + const long ALREADY_EXISTS = 0x44; + + const long NO_OBJECT_CLASS_MODS = 0x45; + + /** + * reserved CLDAP + */ + const long RESULTS_TOO_LARGE = 0x46; + + /** + * new in LDAPv3 + */ + const long AFFECTS_MULTIPLE_DSAS = 0x47; + + const long OTHER = 0x50; + + const long SERVER_DOWN = 0x51; + + const long LOCAL_ERROR = 0x52; + + const long ENCODING_ERROR = 0x53; + + const long DECODING_ERROR = 0x54; + + const long TIMEOUT = 0x55; + + const long AUTH_UNKNOWN = 0x56; + + const long FILTER_ERROR = 0x57; + + const long USER_CANCELLED = 0x58; + + const long PARAM_ERROR = 0x59; + + const long NO_MEMORY = 0x5a; + + const long CONNECT_ERROR = 0x5b; + + /** + * new in LDAPv3 + */ + const long NOT_SUPPORTED = 0x5c; + + /** + * new in LDAPv3 + */ + const long CONTROL_NOT_FOUND = 0x5d; + + /** + * new in LDAPv3 + */ + const long NO_RESULTS_RETURNED = 0x5e; + + /** + * new in LDAPv3 + */ + const long MORE_RESULTS_TO_RETURN = 0x5f; + + /** + * new in LDAPv3 + */ + const long CLIENT_LOOP = 0x60; + + /** + * new in LDAPv3 + */ + const long REFERRAL_LIMIT_EXCEEDED = 0x61; +}; + +/* + * Map these errors codes into the nsresult namespace in C++ + */ +%{C++ + +#define NS_ERROR_LDAP_OPERATIONS_ERROR \ + NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_LDAP, \ + nsILDAPErrors::OPERATIONS_ERROR) + +#define NS_ERROR_LDAP_PROTOCOL_ERROR \ + NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_LDAP, \ + nsILDAPErrors::PROTOCOL_ERROR) + +#define NS_ERROR_LDAP_TIMELIMIT_EXCEEDED \ + NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_LDAP, \ + nsILDAPErrors::TIMELIMIT_EXCEEDED) + +#define NS_ERROR_LDAP_SIZELIMIT_EXCEEDED \ + NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_LDAP, \ + nsILDAPErrors::SIZELIMIT_EXCEEDED) + +#define NS_ERROR_LDAP_COMPARE_FALSE \ + NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_LDAP, \ + nsILDAPErrors::COMPARE_FALSE) + +#define NS_ERROR_LDAP_COMPARE_TRUE \ + NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_LDAP, \ + nsILDAPErrors::COMPARE_TRUE) + +#define NS_ERROR_LDAP_STRONG_AUTH_NOT_SUPPORTED \ + NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_LDAP, \ + nsILDAPErrors::STRONG_AUTH_NOT_SUPPORTED) + +#define NS_ERROR_LDAP_STRONG_AUTH_REQUIRED \ + NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_LDAP, \ + nsILDAPErrors::STRONG_AUTH_REQUIRED) + +#define NS_ERROR_LDAP_PARTIAL_RESULTS \ + NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_LDAP, \ + nsILDAPErrors::PARTIAL_RESULTS) + +#define NS_ERROR_LDAP_REFERRAL \ + NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_LDAP, \ + nsILDAPErrors::REFERRAL) + +#define NS_ERROR_LDAP_ADMINLIMIT_EXCEEDED \ + NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_LDAP, \ + nsILDAPErrors::ADMINLIMIT_EXCEEDED) + +#define NS_ERROR_LDAP_UNAVAILABLE_CRITICAL_EXTENSION \ + NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_LDAP, \ + nsILDAPErrors::UNAVAILABLE_CRITICAL_EXTENSION) + +#define NS_ERROR_LDAP_CONFIDENTIALITY_REQUIRED \ + NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_LDAP, \ + nsILDAPErrors::CONFIDENTIALITY_REQUIRED) + +#define NS_ERROR_LDAP_SASL_BIND_IN_PROGRESS \ + NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_LDAP, \ + nsILDAPErrors::SASL_BIND_IN_PROGRESS) + +#define NS_ERROR_LDAP_NO_SUCH_ATTRIBUTE \ + NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_LDAP, \ + nsILDAPErrors::NO_SUCH_ATTRIBUTE) + +#define NS_ERROR_LDAP_UNDEFINED_TYPE \ + NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_LDAP, \ + nsILDAPErrors::UNDEFINED_TYPE) + +#define NS_ERROR_LDAP_INAPPROPRIATE_MATCHING \ + NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_LDAP, \ + nsILDAPErrors::INAPPROPRIATE_MATCHING) + +#define NS_ERROR_LDAP_CONSTRAINT_VIOLATION \ + NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_LDAP, \ + nsILDAPErrors::CONSTRAINT_VIOLATION) + +#define NS_ERROR_LDAP_TYPE_OR_VALUE_EXISTS \ + NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_LDAP, \ + nsILDAPErrors::TYPE_OR_VALUE_EXISTS) + +#define NS_ERROR_LDAP_INVALID_SYNTAX \ + NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_LDAP, \ + nsILDAPErrors::INVALID_SYNTAX) + +#define NS_ERROR_LDAP_NO_SUCH_OBJECT \ + NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_LDAP, \ + nsILDAPErrors::NO_SUCH_OBJECT) + +#define NS_ERROR_LDAP_ALIAS_PROBLEM \ + NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_LDAP, \ + nsILDAPErrors::ALIAS_PROBLEM) + +#define NS_ERROR_LDAP_INVALID_DN_SYNTAX \ + NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_LDAP, \ + nsILDAPErrors::INVALID_DN_SYNTAX) + +#define NS_ERROR_LDAP_IS_LEAF \ + NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_LDAP, \ + nsILDAPErrors::IS_LEAF) + +#define NS_ERROR_LDAP_ALIAS_DEREF_PROBLEM \ + NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_LDAP, \ + nsILDAPErrors::ALIAS_DEREF_PROBLEM) + +#define NS_ERROR_LDAP_INAPPROPRIATE_AUTH \ + NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_LDAP, \ + nsILDAPErrors::INAPPROPRIATE_AUTH) + +#define NS_ERROR_LDAP_INVALID_CREDENTIALS \ + NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_LDAP, \ + nsILDAPErrors::INVALID_CREDENTIALS) + +#define NS_ERROR_LDAP_INSUFFICIENT_ACCESS \ + NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_LDAP, \ + nsILDAPErrors::INSUFFICIENT_ACCESS) + +#define NS_ERROR_LDAP_BUSY \ + NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_LDAP, \ + nsILDAPErrors::BUSY) + +#define NS_ERROR_LDAP_UNAVAILABLE \ + NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_LDAP, \ + nsILDAPErrors::UNAVAILABLE) + +#define NS_ERROR_LDAP_UNWILLING_TO_PERFORM \ + NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_LDAP, \ + nsILDAPErrors::UNWILLING_TO_PERFORM) + +#define NS_ERROR_LDAP_LOOP_DETECT \ + NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_LDAP, \ + nsILDAPErrors::LOOP_DETECT) + +#define NS_ERROR_LDAP_SORT_CONTROL_MISSING \ + NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_LDAP, \ + nsILDAPErrors::SORT_CONTROL_MISSING) + +#define NS_ERROR_LDAP_INDEX_RANGE_ERROR \ + NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_LDAP, \ + nsILDAPErrors::INDEX_RANGE_ERROR) + +#define NS_ERROR_LDAP_NAMING_VIOLATION \ + NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_LDAP, \ + nsILDAPErrors::NAMING_VIOLATION) + +#define NS_ERROR_LDAP_OBJECT_CLASS_VIOLATION \ + NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_LDAP, \ + nsILDAPErrors::OBJECT_CLASS_VIOLATION) + +#define NS_ERROR_LDAP_NOT_ALLOWED_ON_NONLEAF \ + NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_LDAP, \ + nsILDAPErrors::NOT_ALLOWED_ON_NONLEAF) + +#define NS_ERROR_LDAP_NOT_ALLOWED_ON_RDN \ + NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_LDAP, \ + nsILDAPErrors::NOT_ALLOWED_ON_RDN) + +#define NS_ERROR_LDAP_ALREADY_EXISTS \ + NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_LDAP, \ + nsILDAPErrors::ALREADY_EXISTS) + +#define NS_ERROR_LDAP_NO_OBJECT_CLASS_MODS \ + NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_LDAP, \ + nsILDAPErrors::NO_OBJECT_CLASS_MODS) + +#define NS_ERROR_LDAP_RESULTS_TOO_LARGE \ + NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_LDAP, \ + nsILDAPErrors::RESULTS_TOO_LARGE) + +#define NS_ERROR_LDAP_AFFECTS_MULTIPLE_DSAS \ + NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_LDAP, \ + nsILDAPErrors::AFFECTS_MULTIPLE_DSAS) + +#define NS_ERROR_LDAP_OTHER \ + NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_LDAP, \ + nsILDAPErrors::OTHER) + +#define NS_ERROR_LDAP_SERVER_DOWN \ + NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_LDAP, \ + nsILDAPErrors::SERVER_DOWN) + +#define NS_ERROR_LDAP_LOCAL_ERROR \ + NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_LDAP, \ + nsILDAPErrors::LOCAL_ERROR) + +#define NS_ERROR_LDAP_ENCODING_ERROR \ + NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_LDAP, \ + nsILDAPErrors::ENCODING_ERROR) + +#define NS_ERROR_LDAP_DECODING_ERROR \ + NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_LDAP, \ + nsILDAPErrors::DECODING_ERROR) + +#define NS_ERROR_LDAP_TIMEOUT \ + NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_LDAP, \ + nsILDAPErrors::TIMEOUT) + +#define NS_ERROR_LDAP_AUTH_UNKNOWN \ + NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_LDAP, \ + nsILDAPErrors::AUTH_UNKNOWN) + +#define NS_ERROR_LDAP_FILTER_ERROR \ + NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_LDAP, \ + nsILDAPErrors::FILTER_ERROR) + +#define NS_ERROR_LDAP_USER_CANCELLED \ + NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_LDAP, \ + nsILDAPErrors::USER_CANCELLED) + +#define NS_ERROR_LDAP_PARAM_ERROR \ + NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_LDAP, \ + nsILDAPErrors::PARAM_ERROR) + +#define NS_ERROR_LDAP_NO_MEMORY \ + NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_LDAP, \ + nsILDAPErrors::NO_MEMORY) + +#define NS_ERROR_LDAP_CONNECT_ERROR \ + NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_LDAP, \ + nsILDAPErrors::CONNECT_ERROR) + +#define NS_ERROR_LDAP_NOT_SUPPORTED \ + NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_LDAP, \ + nsILDAPErrors::NOT_SUPPORTED) + +#define NS_ERROR_LDAP_CONTROL_NOT_FOUND \ + NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_LDAP, \ + nsILDAPErrors::CONTROL_NOT_FOUND) + +#define NS_ERROR_LDAP_NO_RESULTS_RETURNED \ + NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_LDAP, \ + nsILDAPErrors::NO_RESULTS_RETURNED) + +#define NS_ERROR_LDAP_MORE_RESULTS_TO_RETURN \ + NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_LDAP, \ + nsILDAPErrors::MORE_RESULTS_TO_RETURN) + +#define NS_ERROR_LDAP_CLIENT_LOOP \ + NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_LDAP, \ + nsILDAPErrors::CLIENT_LOOP) + +#define NS_ERROR_LDAP_REFERRAL_LIMIT_EXCEEDED \ + NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_LDAP, \ + nsILDAPErrors::REFERRAL_LIMIT_EXCEEDED) + +%} diff --git a/comm/mailnews/addrbook/public/nsILDAPMessage.idl b/comm/mailnews/addrbook/public/nsILDAPMessage.idl new file mode 100644 index 0000000000..f6dd94efc2 --- /dev/null +++ b/comm/mailnews/addrbook/public/nsILDAPMessage.idl @@ -0,0 +1,167 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- + * + * 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/. */ + +#include "nsISupports.idl" + +interface nsILDAPBERValue; +interface nsILDAPOperation; + +%{C++ +#define NS_LDAPMESSAGE_CONTRACTID "@mozilla.org/network/ldap-message;1" +%} + +[scriptable, uuid(973ff50f-2002-4f0c-b57d-2242156139a2)] +interface nsILDAPMessage : nsISupports +{ + /** + * The Distinguished Name of the entry associated with this message. + * + * @exception NS_ERROR_OUT_OF_MEMORY ran out of memory + * @exception NS_ERROR_ILLEGAL_VALUE null pointer passed in + * @exception NS_ERROR_LDAP_DECODING_ERROR problem during BER-decoding + * @exception NS_ERROR_UNEXPECTED bug or memory corruption + */ + readonly attribute AUTF8String dn; + + /** + * Get all the attributes in this message. + * + * @exception NS_ERROR_OUT_OF_MEMORY + * @exception NS_ERROR_ILLEGAL_VALUE null pointer passed in + * @exception NS_ERROR_UNEXPECTED bug or memory corruption + * @exception NS_ERROR_LDAP_DECODING_ERROR problem during BER decoding + * + * @return array of all attributes in the current message + */ + Array getAttributes(); + + /** + * Get an array of all the attribute values in this message. + * + * @param attr The attribute whose values are to be returned + * + * @exception NS_ERROR_UNEXPECTED Bug or memory corruption + * @exception NS_ERROR_LDAP_DECODING_ERROR Attribute not found or other + * decoding error. + * @exception NS_ERROR_OUT_OF_MEMORY + * + * @return Array of values for attr. + */ + Array getValues(in string attr); + + /** + * The operation this message originated from + * + * @exception NS_ERROR_NULL_POINTER NULL pointer to getter + */ + readonly attribute nsILDAPOperation operation; + + /** + * The result code (aka lderrno) for this message. + * + * IDL definitions for these constants live in nsILDAPErrors.idl. + * + * @exception NS_ERROR_ILLEGAL_VALUE null pointer passed in + */ + readonly attribute long errorCode; + + /** + * The result type of this message. Possible types listed below, the + * values chosen are taken from the draft-ietf-ldapext-ldap-c-api-04.txt + * and are the same ones used in the ldap.h include file from the Mozilla + * LDAP C SDK. + * + * @exception NS_ERROR_ILLEGAL_VALUE null pointer passed in + * @exception NS_ERROR_UNEXPECTED internal error (possible memory + * corruption) + */ + readonly attribute long type; + + /** + * Result of a bind operation + */ + const long RES_BIND = 0x61; + + /** + * An entry found in an search operation. + */ + const long RES_SEARCH_ENTRY = 0x64; + + /** + * An LDAPv3 search reference (a referral to another server) + */ + const long RES_SEARCH_REFERENCE = 0x73; + + /** + * The result of a search operation (i.e. the search is done; no more + * entries to follow). + */ + const long RES_SEARCH_RESULT = 0x65; + + /** + * The result of a modify operation. + */ + const long RES_MODIFY = 0x67; + + /** + * The result of an add operation + */ + const long RES_ADD = 0x69; + + /** + * The result of a delete operation + */ + const long RES_DELETE = 0x6B; + + /** + * The result of an modify DN operation + */ + const long RES_MODDN = 0x6D; + + /** + * The result of a compare operation + */ + const long RES_COMPARE = 0x6F; + + /** + * The result of an LDAPv3 extended operation + */ + const long RES_EXTENDED = 0x78; + + /** + * get an LDIF-like string representation of this message + * + * @return unicode encoded string representation. + */ + wstring toUnicode(); + + /** + * Additional error information optionally sent by the server. + */ + readonly attribute AUTF8String errorMessage; + + /** + * In LDAPv3, when the server returns any of the following errors: + * NO_SUCH_OBJECT, ALIAS_PROBLEM, INVALID_DN_SYNTAX, ALIAS_DEREF_PROBLEM, + * it also returns the closest existing DN to the entry requested. + */ + readonly attribute AUTF8String matchedDn; + + /** + * Get an array of all the attribute values in this message (a wrapper + * around the LDAP C SDK's get_values_len()). + * + * @param attr The attribute whose values are to be returned + * + * @exception NS_ERROR_UNEXPECTED Bug or memory corruption + * @exception NS_ERROR_LDAP_DECODING_ERROR Attribute not found or other + * decoding error. + * @exception NS_ERROR_OUT_OF_MEMORY + * + * @return Array of nsILDAPBERValue objects. + */ + Array getBinaryValues(in string attr); +}; diff --git a/comm/mailnews/addrbook/public/nsILDAPMessageListener.idl b/comm/mailnews/addrbook/public/nsILDAPMessageListener.idl new file mode 100644 index 0000000000..2907840df5 --- /dev/null +++ b/comm/mailnews/addrbook/public/nsILDAPMessageListener.idl @@ -0,0 +1,48 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- + * + * 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/. */ + +#include "nsISupports.idl" + +interface nsILDAPMessage; +interface nsILDAPConnection; +interface nsITransportSecurityInfo; + +/** + * A callback interface to be implemented by any objects that want to + * receive results from an nsILDAPOperation (ie nsILDAPMessages) as they + * come in. + */ +[scriptable, uuid(dc721d4b-3ff2-4387-a80c-5e29545f774a)] +interface nsILDAPMessageListener : nsISupports +{ + /** + * Invoked when Init has completed successfully LDAP operations can + * proceed. + */ + void onLDAPInit(); + + /** + * Messages from LDAP operations are passed back via this function. + * + * @param aMessage The message that was returned, NULL if none was. + * + * XXX semantics of NULL? + */ + void onLDAPMessage(in nsILDAPMessage aMessage); + + + /** + * Indicates that an error has occurred - either during init, or due to + * an LDAP operation. + * + * @param status The error code. + * @param secInfo The securityInfo object for the connection, if status + * is a security (NSS) error. Null otherwise. + * @param location If status is an NSS error code, this holds the location + * of the failed operation (":"). + */ + void onLDAPError(in nsresult status, in nsITransportSecurityInfo secInfo, in ACString location); +}; diff --git a/comm/mailnews/addrbook/public/nsILDAPModification.idl b/comm/mailnews/addrbook/public/nsILDAPModification.idl new file mode 100644 index 0000000000..453efc4aaa --- /dev/null +++ b/comm/mailnews/addrbook/public/nsILDAPModification.idl @@ -0,0 +1,57 @@ +/* -*- 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/. */ + +#include "nsISupports.idl" + +interface nsILDAPBERValue; + +[scriptable, uuid(f64ef501-0623-11d6-a7f2-b65476fc49dc)] +interface nsILDAPModification : nsISupports +{ + /** + * The operation to perform. + */ + attribute long operation; + + /** + * Add operation + */ + const long MOD_ADD = 0x00; + + /** + * Delete operation + */ + const long MOD_DELETE = 0x01; + + /** + * Replace operation + */ + const long MOD_REPLACE = 0x02; + + /** + * Values are BER encoded + */ + const long MOD_BVALUES = 0x80; + + /** + * The attribute to modify. + */ + attribute ACString type; + + /** + * The array of values this modification sets for the attribute + */ + attribute Array values; + + /** + * Function that allows all the attributes to be set at the same + * time to avoid multiple function calls. + */ + void setUpModification(in long aOperation, in ACString aType, + in Array aValues); + + void setUpModificationOneValue(in long aOperation, in ACString aType, + in nsILDAPBERValue aValue); +}; diff --git a/comm/mailnews/addrbook/public/nsILDAPOperation.idl b/comm/mailnews/addrbook/public/nsILDAPOperation.idl new file mode 100644 index 0000000000..3f3c9562c4 --- /dev/null +++ b/comm/mailnews/addrbook/public/nsILDAPOperation.idl @@ -0,0 +1,278 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- + * + * 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/. */ + +#include "nsISupports.idl" +#include "nsILDAPConnection.idl" +#include "nsIAuthModule.idl" + +interface nsILDAPMessage; +interface nsILDAPMessageListener; +interface nsILDAPModification; +interface nsILDAPControl; + +%{C++ +#define NS_LDAPOPERATION_CONTRACTID "@mozilla.org/network/ldap-operation;1" +%} + +// XXXdmose check to make sure ctl-related err codes documented + +typedef uint32_t PRIntervalTime; + +[scriptable, uuid(4dfb1b19-fc8f-4525-92e7-f97b78a9747a)] +interface nsILDAPOperation : nsISupports +{ + /** + * The connection this operation is on. + * + * @exception NS_ERROR_ILLEGAL_VALUE a NULL pointer was passed in + */ + readonly attribute nsILDAPConnection connection; + + /** + * Callback for individual result messages related to this operation (set + * by the init() method). This is actually an nsISupports proxy object, + * as the callback will happen from another thread. + * + * @exception NS_ERROR_ILLEGAL_VALUE a NULL pointer was passed in + */ + readonly attribute nsILDAPMessageListener messageListener; + + /** + * The message-id associated with this operation. + * + * @exception NS_ERROR_ILLEGAL_VALUE a NULL pointer was passed in + */ + readonly attribute long messageID; + + /** + * private parameter (anything caller desires) + */ + attribute nsISupports closure; + /** + * number of the request for compare that the request is still valid. + */ + attribute unsigned long requestNum; + + /** + * No time and/or size limit specified + */ + const long NO_LIMIT = 0; + + /** + * If specified, these arrays of nsILDAPControls are passed into the LDAP + * C SDK for any extended operations (ie method calls on this interface + * ending in "Ext"). + */ + attribute Array serverControls; + attribute Array clientControls; + + /** + * Initializes this operation. Must be called prior to initiating + * any actual operations. Note that by default, the aMessageListener + * callbacks happen on the LDAP connection thread. If you need them + * to happen on the main thread (or any other thread), then you should + * created an nsISupports proxy object and pass that in. + * + * @param aConnection connection this operation should use + * @param aMessageListener interface used to call back the results. + * @param aClosure private parameter (anything caller desires) + * + * @exception NS_ERROR_ILLEGAL_VALUE a NULL pointer was passed in + * @exception NS_ERROR_UNEXPECTED failed to get connection handle + */ + void init(in nsILDAPConnection aConnection, + in nsILDAPMessageListener aMessageListener, + in nsISupports aClosure); + + /** + * Asynchronously authenticate to the LDAP server. + * + * @param passwd the password used for binding; NULL for anon-binds + * + * @exception NS_ERROR_LDAP_ENCODING_ERROR problem encoding bind request + * @exception NS_ERROR_LDAP_SERVER_DOWN server down (XXX rebinds?) + * @exception NS_ERROR_LDAP_CONNECT_ERROR connection failed or lost + * @exception NS_ERROR_OUT_OF_MEMORY ran out of memory + * @exception NS_ERROR_UNEXPECTED internal error + */ + void simpleBind(in AUTF8String passwd); + + /** + * Asynchronously perform a SASL bind against the LDAP server + * + * @param service the host name of the service being connected to + * @param mechanism the name of the SASL mechanism in use + * @param authModuleType the type of auth module to be used to perform the operation + * + */ + void saslBind(in ACString service, in ACString mechanism, + in ACString authModuleType); + + /** + * Continue a SASL bind operation + * + * @param token the next SASL token to send to the server + * @param tokenLen the length of the token to send + * + */ + void saslStep(in string token, in unsigned long tokenLen); + + /** + * Kicks off an asynchronous add request. The "ext" stands for + * "extensions", and is intended to convey that this method will + * eventually support the extensions described in the + * draft-ietf-ldapext-ldap-c-api-04.txt Internet Draft. + * + * @param aBaseDn Base DN to add + * @param aModCount Number of modifications + * @param aMods Array of modifications + * + * @exception NS_ERROR_NOT_INITIALIZED operation not initialized + * @exception NS_ERROR_INVALID_ARG invalid argument + * @exception NS_ERROR_LDAP_ENCODING_ERROR error during BER-encoding + * @exception NS_ERROR_LDAP_SERVER_DOWN the LDAP server did not + * receive the request or the + * connection was lost + * @exception NS_ERROR_OUT_OF_MEMORY ran out of memory + * @exception NS_ERROR_LDAP_NOT_SUPPORTED not supported in the version + * of the LDAP protocol that the + * client is using + * @exception NS_ERROR_UNEXPECTED an unexpected error has + * occurred + * + * XXX doesn't currently handle LDAPControl params + */ + void addExt(in AUTF8String aBaseDn, in Array aMods); + + /** + * Kicks off an asynchronous delete request. The "ext" stands for + * "extensions", and is intended to convey that this method will + * eventually support the extensions described in the + * draft-ietf-ldapext-ldap-c-api-04.txt Internet Draft. + * + * @param aBaseDn Base DN to delete + * + * @exception NS_ERROR_NOT_INITIALIZED operation not initialized + * @exception NS_ERROR_INVALID_ARG invalid argument + * @exception NS_ERROR_LDAP_ENCODING_ERROR error during BER-encoding + * @exception NS_ERROR_LDAP_SERVER_DOWN the LDAP server did not + * receive the request or the + * connection was lost + * @exception NS_ERROR_OUT_OF_MEMORY ran out of memory + * @exception NS_ERROR_LDAP_NOT_SUPPORTED not supported in the version + * of the LDAP protocol that the + * client is using + * @exception NS_ERROR_UNEXPECTED an unexpected error has + * occurred + * + * XXX doesn't currently handle LDAPControl params + */ + void deleteExt(in AUTF8String aBaseDn); + + /** + * Kicks off an asynchronous modify request. The "ext" stands for + * "extensions", and is intended to convey that this method will + * eventually support the extensions described in the + * draft-ietf-ldapext-ldap-c-api-04.txt Internet Draft. + * + * @param aBaseDn Base DN to modify + * @param aModCount Number of modifications + * @param aMods Array of modifications + * + * @exception NS_ERROR_NOT_INITIALIZED operation not initialized + * @exception NS_ERROR_INVALID_ARG invalid argument + * @exception NS_ERROR_LDAP_ENCODING_ERROR error during BER-encoding + * @exception NS_ERROR_LDAP_SERVER_DOWN the LDAP server did not + * receive the request or the + * connection was lost + * @exception NS_ERROR_OUT_OF_MEMORY ran out of memory + * @exception NS_ERROR_LDAP_NOT_SUPPORTED not supported in the version + * of the LDAP protocol that the + * client is using + * @exception NS_ERROR_UNEXPECTED an unexpected error has + * occurred + * + * XXX doesn't currently handle LDAPControl params + */ + void modifyExt(in AUTF8String aBaseDn, in Array aMods); + + /** + * Kicks off an asynchronous rename request. + * + * @param aBaseDn Base DN to rename + * @param aNewRDn New relative DN + * @param aNewParent DN of the new parent under which to move the + * entry + * @param aDeleteOldRDn Indicates whether to remove the old relative + * DN as a value in the entry or not + * + * @exception NS_ERROR_NOT_INITIALIZED operation not initialized + * @exception NS_ERROR_INVALID_ARG invalid argument + * @exception NS_ERROR_LDAP_ENCODING_ERROR error during BER-encoding + * @exception NS_ERROR_LDAP_SERVER_DOWN the LDAP server did not + * receive the request or the + * connection was lost + * @exception NS_ERROR_OUT_OF_MEMORY ran out of memory + * @exception NS_ERROR_LDAP_NOT_SUPPORTED not supported in the version + * of the LDAP protocol that the + * client is using + * @exception NS_ERROR_UNEXPECTED an unexpected error has + * occurred + * + * XXX doesn't currently handle LDAPControl params + */ + void rename(in AUTF8String aBaseDn, in AUTF8String aNewRDn, + in AUTF8String aNewParent, in boolean aDeleteOldRDn); + + /** + * Kicks off an asynchronous search request. The "ext" stands for + * "extensions", and is intended to convey that this method will + * eventually support the extensions described in the + * draft-ietf-ldapext-ldap-c-api-04.txt Internet Draft. + * + * @param aBaseDn Base DN to search + * @param aScope One of SCOPE_{BASE,ONELEVEL,SUBTREE} + * @param aFilter Search filter + * @param aAttributes Comma separated list of values, holding the + * attributes we need + * @param aTimeOut How long to wait + * @param aSizeLimit Maximum number of entries to return. + * + * @exception NS_ERROR_NOT_INITIALIZED operation not initialized + * @exception NS_ERROR_LDAP_ENCODING_ERROR error during BER-encoding + * @exception NS_ERROR_LDAP_SERVER_DOWN the LDAP server did not + * receive the request or the + * connection was lost + * @exception NS_ERROR_OUT_OF_MEMORY ran out of memory + * @exception NS_ERROR_INVALID_ARG invalid argument + * @exception NS_ERROR_LDAP_NOT_SUPPORTED not supported in the version + * of the LDAP protocol that the + * client is using + * @exception NS_ERROR_LDAP_FILTER_ERROR + * @exception NS_ERROR_UNEXPECTED + */ + void searchExt(in AUTF8String aBaseDn, in int32_t aScope, + in AUTF8String aFilter, in ACString aAttributes, + in PRIntervalTime aTimeOut, in int32_t aSizeLimit); + + /** + * Cancels an async operation that is in progress. + * + * XXX controls not supported yet + * + * @exception NS_ERROR_NOT_IMPLEMENTED server or client controls + * were set on this object + * @exception NS_ERROR_NOT_INITIALIZED operation not initialized + * @exception NS_ERROR_LDAP_ENCODING_ERROR error during BER-encoding + * @exception NS_ERROR_LDAP_SERVER_DOWN the LDAP server did not + * receive the request or the + * connection was lost + * @exception NS_ERROR_OUT_OF_MEMORY out of memory + * @exception NS_ERROR_INVALID_ARG invalid argument + * @exception NS_ERROR_UNEXPECTED internal error + */ + void abandonExt(); +}; diff --git a/comm/mailnews/addrbook/public/nsILDAPService.idl b/comm/mailnews/addrbook/public/nsILDAPService.idl new file mode 100644 index 0000000000..6396dafc21 --- /dev/null +++ b/comm/mailnews/addrbook/public/nsILDAPService.idl @@ -0,0 +1,43 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- + * + * 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/. */ + +#include "nsISupports.idl" + +/** + * This interface is a catch-all for any LDAP functionality that is needed + * in XPCOM and not provided elsewhere. + */ +[scriptable, uuid(69de6fbc-2e8c-4482-bf14-358d68b785d1)] +interface nsILDAPService : nsISupports { + + /** + * Generates and returns an LDAP search filter by substituting + * aValue, aAttr, aPrefix, and aSuffix into aPattern. + * + * Exposes the functionality of ldap_create_filter() via XPCOM. + * + * There is some documentation on the filter template format + * (passed in via aPattern) here: + * https://docs.oracle.com/cd/E19957-01/817-6707/filter.html + * + * @param aMaxSize maximum size (in char) of string to be + * created and returned (including final \0) + * @param aPattern pattern to be used for the filter + * @param aPrefix prefix to prepend to the filter + * @param aSuffix suffix to be appended to the filer + * @param aAttr replacement for %a in the pattern + * @param aValue replacement for %v in the pattern + * + * @exception NS_ERROR_INVALID_ARG invalid parameter passed in + * @exception NS_ERROR_OUT_OF_MEMORY allocation failed + * @exception NS_ERROR_NOT_AVAILABLE filter longer than maxsiz chars + * @exception NS_ERROR_UNEXPECTED ldap_create_filter returned + * unexpected error code + */ + AUTF8String createFilter(in unsigned long aMaxSize, in AUTF8String aPattern, + in AUTF8String aPrefix, in AUTF8String aSuffix, + in AUTF8String aAttr, in AUTF8String aValue); +}; diff --git a/comm/mailnews/addrbook/public/nsILDAPSyncQuery.idl b/comm/mailnews/addrbook/public/nsILDAPSyncQuery.idl new file mode 100644 index 0000000000..d2709ed2a2 --- /dev/null +++ b/comm/mailnews/addrbook/public/nsILDAPSyncQuery.idl @@ -0,0 +1,27 @@ +/* -*- Mode: IDL; 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/. */ + +#include "nsISupports.idl" +interface nsILDAPURL; + + +[scriptable, uuid (0308fb36-1dd2-11b2-b16f-8510e8c5311a)] +interface nsILDAPSyncQuery : nsISupports { + + /** + * getQueryResults + * + * Create a new LDAP connection do a synchronous LDAP search and return + * the results. + * @param aServerURL - LDAP URL with parameters to a LDAP search + * ("ldap://host/base?attributes?one/sub?filter") + * @param aProtocolVersion - LDAP protocol version to use for connection + * (nsILDAPConnection.idl has symbolic constants) + * @return results + */ + wstring getQueryResults (in nsILDAPURL aServerURL, + in unsigned long aProtocolVersion); + +}; diff --git a/comm/mailnews/addrbook/public/nsILDAPURL.idl b/comm/mailnews/addrbook/public/nsILDAPURL.idl new file mode 100644 index 0000000000..fd0c3e28ec --- /dev/null +++ b/comm/mailnews/addrbook/public/nsILDAPURL.idl @@ -0,0 +1,170 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- + * + * 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/. */ + +#include "nsIURI.idl" + +%{C++ +#define NS_LDAPURL_CONTRACTID "@mozilla.org/network/ldap-url;1" +%} + +/** + * Strings in methods inherited from nsIURI, which are using XPIDL + * |string| types, are expected to be UTF8 encoded. All such strings + * in this interface, except attribute types (e.g. "cn"), should in fact + * be UTF8. It's important to remember that attributes can not be UTF8, + * they can only be of a limited subset of ASCII (see RFC 2251). + */ + +[scriptable, builtinclass, uuid(8e3a6d33-2e68-40ba-8f94-6ac03f69066e)] +interface nsILDAPURL : nsIURI { + /** + * Initialize an LDAP URL + * + * @param aUrlType - one of the URLTYPE_ flags @seealso nsIStandardURL + * @param aDefaultPort - if the port parsed from the URL string matches + * this port, then the port will be removed from the + * canonical form of the URL. + * @param aSpec - URL string. + * @param aOriginCharset - the charset from which this URI string + * originated. this corresponds to the charset + * that should be used when communicating this + * URI to an origin server, for example. if + * null, then provide aBaseURI implements this + * interface, the origin charset of aBaseURI will + * be assumed, otherwise defaulting to UTF-8 (i.e., + * no charset transformation from aSpec). + * @param aBaseURI - if null, aSpec must specify an absolute URI. + * otherwise, aSpec will be resolved relative + * to aBaseURI. + */ + void init(in unsigned long aUrlType, + in long aDefaultPort, + in AUTF8String aSpec, + in string aOriginCharset, + in nsIURI aBaseURI); + + /** + * The distinguished name of the URL (ie the base DN for the search). + * This string is expected to be a valid UTF8 string. + * + * for the getter: + * + * @exception NS_ERROR_NULL_POINTER NULL pointer to GET method + * @exception NS_ERROR_OUT_OF_MEMORY Ran out of memory + */ + attribute AUTF8String dn; + + /** + * The attributes to get for this URL, in comma-separated format. If the + * list is empty, all attributes are requested. + */ + attribute ACString attributes; + + /** + * Add one attribute to the array of attributes to request. If the + * attribute is already in our array, this becomes a noop. + * + * @param aAttribute An LDAP attribute (e.g. "cn") + */ + void addAttribute(in ACString aAttribute); + + /** + * Remove one attribute from the array of attributes to request. If + * the attribute didn't exist in the array, this becomes a noop. + * + * @param aAttribute An LDAP attribute (e.g. "cn") + * @exception NS_ERROR_OUT_OF_MEMORY Ran out of memory + */ + void removeAttribute(in ACString aAttribute); + + /** + * Test if an attribute is in our list of attributes already + * + * @param aAttribute An LDAP attribute (e.g. "cn") + * @return boolean Truth value + * @exception NS_ERROR_NULL_POINTER NULL pointer to GET method + */ + boolean hasAttribute(in ACString aAttribute); + + /** + * The scope of the search. defaults to SCOPE_BASE. + * + * @exception NS_ERROR_NULL_POINTER NULL pointer to GET method + * @exception NS_ERROR_MALFORMED_URI Illegal base to SET method + */ + attribute long scope; + + /** + * Search just the base object + */ + const long SCOPE_BASE = 0; + + /** + * Search only the children of the base object + */ + const long SCOPE_ONELEVEL = 1; + + /** + * Search the entire subtree under and including the base object + */ + const long SCOPE_SUBTREE = 2; + + /** + * The search filter. "(objectClass=*)" is the default. + */ + attribute AUTF8String filter; + + /** + * Any options defined for this URL (check options using a bitwise and) + * + * @exception NS_ERROR_NULL_POINTER NULL pointer to GET method + * @exception NS_ERROR_OUT_OF_MEMORY Ran out of memory + */ + attribute unsigned long options; + + /** + * If this is set/true, this is an ldaps: URL, not an ldap: URL + */ + const unsigned long OPT_SECURE = 0x01; +}; + +/** + * A structure to represent an LDAP URL. + */ +[scriptable, uuid(c0376fe9-2c7c-4f7b-a991-db9c3d95c1bb)] +interface nsILDAPURLParserResult : nsISupports { + /** The host name of the URL. */ + readonly attribute AUTF8String host; + + /** The port number of the URL. */ + readonly attribute long port; + + /** The distinguished name of the URL. */ + readonly attribute AUTF8String dn; + + /** The attributes to request when searching. */ + readonly attribute ACString attributes; + + /** The scope to use when searching. */ + readonly attribute long scope; + + /** The filter to use when searching. */ + readonly attribute AUTF8String filter; + + /** The options of the URL. */ + readonly attribute unsigned long options; +}; + +/** + * A helper module to parse a string to an LDAP URL. + */ +[scriptable, uuid(340098c0-a881-49ab-a5e8-f79d04e6651c)] +interface nsILDAPURLParser : nsISupports { + /** + * Parse a string to an LDAP URL. + */ + nsILDAPURLParserResult parse(in AUTF8String aSpec); +}; diff --git a/comm/mailnews/addrbook/public/nsIMsgVCardService.idl b/comm/mailnews/addrbook/public/nsIMsgVCardService.idl new file mode 100644 index 0000000000..b2d542f14c --- /dev/null +++ b/comm/mailnews/addrbook/public/nsIMsgVCardService.idl @@ -0,0 +1,36 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* 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/. */ + +#include "nsISupports.idl" + +interface nsIAbCard; + +[scriptable, uuid(8b6ae917-676d-4f1f-bbad-2ecc9be0d9b1)] +interface nsIMsgVCardService : nsISupports { + + /** + * Translates a vCard string into a nsIAbCard. + * + * @param vCardStr - The string containing the vCard data. + * @return - A card containing the translated vCard data. + */ + nsIAbCard vCardToAbCard(in AString vCardStr); + + /** + * Translates an URL-encoded vCard string into a nsIAbCard. + * + * @param escapedVCardStr - The string containing the vCard data. + * @return - A card containing the translated vCard data. + */ + nsIAbCard escapedVCardToAbCard(in AString escapedVCardStr); + + /** + * Translates a nsIAbCard into an URL-encoded vCard. + * + * @param abCard - A card to be translated. + * @return - The string containing the vCard data. + */ + AString abCardToEscapedVCard(in nsIAbCard abCard); +}; -- cgit v1.2.3