author David Bienvenu <>
Mon, 05 Jul 2010 16:32:44 +0100
changeset 5936 1eb74b7e9acb7df264725547444bf120373a9f52
parent 3439 5c26af85988a8fdd672f22d05452d3ab0009fa5e
child 6897 600b8c098a8263cee93d5d4895352c5f2de21991
permissions -rw-r--r--
Part of bug 575740. Fix some js components in mail/ to work with the new component manager. r=Standard8. Part bustage fix for CLOSED TREE

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

interface nsISimpleEnumerator;
interface nsIVariant;

[scriptable, uuid(97448252-F189-11d4-A422-001083003D0C)]
interface nsIAbPreferMailFormat {
    const unsigned long unknown   = 0;
    const unsigned long plaintext = 1;
    const unsigned long html      = 2;

 * An interface representing an address book card.
 * Fundamentally, it 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
 *   - PreferMailFormat (see nsIAbPreferMailFormat)
 * - Boolean properties:
 *   - AllowRemoteContent
 * - Photo properties:
 *   - PhotoName
 *   - PhotoType
 *   - PhotoURI
[scriptable, uuid(fdac4023-cd19-4e75-9a88-8e48881076ea)]
interface nsIAbCard : nsIAbItem {
   * A list of all the properties that this card has as an enumerator, whose
   * members are all nsIProperty objects.
  readonly attribute nsISimpleEnumerator 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.
   * 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."
   * These functions are marked [noscript] since xpconnect performs automatic
   * type conversion on nsIVariants such that they are not needed for scripts,
   * only for C++ callers.
   * @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.
  [noscript] AString getPropertyAsAString(in string name);
  [noscript] AUTF8String getPropertyAsAUTF8String(in string name);
  [noscript] PRUint32 getPropertyAsUint32(in string name);
  [noscript] boolean getPropertyAsBool(in string name);
  /** @} */

   * @{
   * 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.
   * These functions convert values in the same manner as the default
   * implementation of nsIVariant.
   * @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.
   * The non-variant functions are marked [noscript] since xpconnect uses
   * magic with nsIVariant such that the other functions are not needed,
   * although C++ does need them.
   * @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);
  [noscript] void setPropertyAsAString(in string name, in AString value);
  [noscript] void setPropertyAsAUTF8String(in string name, in AUTF8String value);
  [noscript] void setPropertyAsUint32(in string name, in PRUint32 value);
  [noscript] 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);
   * @{
   * These properties are shorthand for getProperty and setProperty.
  attribute AString firstName;
  attribute AString lastName;
  attribute AString displayName;
  attribute AString primaryEmail;
  /** @} */

   * 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);

   * 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);

   * 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
   *          <tt>a.equals(b) == b.equals(a)</tt> 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);


  attribute boolean isMailList;
   * If isMailList is true then mailListURI
   * will contain the URI of the associated
   * mail list
  attribute string mailListURI;

// A nice list of properties for the benefit of C++ clients
#define kFirstNameProperty          "FirstName"
#define kLastNameProperty           "LastName"
#define kDisplayNameProperty        "DisplayName"
#define kNicknameProperty           "NickName"
#define kPriEmailProperty           "PrimaryEmail"
#define kPreferMailFormatProperty   "PreferMailFormat"
#define kLastModifiedDateProperty   "LastModifiedDate"
#define kPopularityIndexProperty    "PopularityIndex"
#define kAllowRemoteContentProperty "AllowRemoteContent"

#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 kAnniversaryYearProperty    "AnniversaryYear"
#define kAnniversaryMonthProperty   "AnniversaryMonth"
#define kAnniversaryDayProperty     "AnniversaryDay"
#define kBirthYearProperty          "BirthYear"
#define kBirthMonthProperty         "BirthMonth"
#define kBirthDayProperty           "BirthDay"