Bug 450917 - Create and populate nsIAbCollection. r=Standard8, sr=bienvenu
This commit is contained in:
Родитель
fa68466530
Коммит
812af31a77
|
@ -117,8 +117,7 @@ var editContactInlineUI = {
|
||||||
var bundle = document.getElementById("bundle_editContact");
|
var bundle = document.getElementById("bundle_editContact");
|
||||||
|
|
||||||
// Is this address book writeable?
|
// Is this address book writeable?
|
||||||
this._writeable = this._cardDetails.book.operations &
|
this._writeable = !this._cardDetails.book.readOnly;
|
||||||
Components.interfaces.nsIAbDirectory.opWrite;
|
|
||||||
var type = this._writeable ? "edit" : "view";
|
var type = this._writeable ? "edit" : "view";
|
||||||
|
|
||||||
// Update the labels accordingly.
|
// Update the labels accordingly.
|
||||||
|
|
|
@ -1141,8 +1141,7 @@ function setupEmailAddressPopup(emailAddressNode)
|
||||||
|
|
||||||
if (emailAddressNode.cardDetails.card) {
|
if (emailAddressNode.cardDetails.card) {
|
||||||
document.getElementById('addToAddressBookItem').setAttribute('hidden', true);
|
document.getElementById('addToAddressBookItem').setAttribute('hidden', true);
|
||||||
if (emailAddressNode.cardDetails.book.operations &
|
if (!emailAddressNode.cardDetails.book.readOnly) {
|
||||||
Components.interfaces.nsIAbDirectory.opWrite) {
|
|
||||||
document.getElementById('editContactItem').removeAttribute('hidden');
|
document.getElementById('editContactItem').removeAttribute('hidden');
|
||||||
document.getElementById('viewContactItem').setAttribute('hidden', true);
|
document.getElementById('viewContactItem').setAttribute('hidden', true);
|
||||||
}
|
}
|
||||||
|
|
|
@ -120,7 +120,7 @@ function OnLoadNewCard()
|
||||||
if (parentURI)
|
if (parentURI)
|
||||||
gEditCard.selectedAB = parentURI;
|
gEditCard.selectedAB = parentURI;
|
||||||
}
|
}
|
||||||
else if (directory.operations & directory.opWrite)
|
else if (!directory.readOnly)
|
||||||
gEditCard.selectedAB = window.arguments[0].selectedAB;
|
gEditCard.selectedAB = window.arguments[0].selectedAB;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -266,7 +266,7 @@ function OnLoadEditCard()
|
||||||
var abURI = window.arguments[0].abURI;
|
var abURI = window.arguments[0].abURI;
|
||||||
var directory = GetDirectoryFromURI(abURI);
|
var directory = GetDirectoryFromURI(abURI);
|
||||||
|
|
||||||
if (!(directory.operations & directory.opWrite))
|
if (directory.readOnly)
|
||||||
{
|
{
|
||||||
// Set all the editable vcard fields to read only
|
// Set all the editable vcard fields to read only
|
||||||
for (var i = kVcardFields.length; i-- > 0; )
|
for (var i = kVcardFields.length; i-- > 0; )
|
||||||
|
|
|
@ -100,8 +100,7 @@ var DirPaneController =
|
||||||
// If the directory is a mailing list, and it is read-only, return
|
// If the directory is a mailing list, and it is read-only, return
|
||||||
// false.
|
// false.
|
||||||
var abDir = GetDirectoryFromURI(selectedDir);
|
var abDir = GetDirectoryFromURI(selectedDir);
|
||||||
if (abDir.isMailList &&
|
if (abDir.isMailList && abDir.readOnly)
|
||||||
~abDir.operations & abDir.opWrite)
|
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
// If the selected directory is an ldap directory
|
// If the selected directory is an ldap directory
|
||||||
|
|
|
@ -47,9 +47,10 @@ MODULE = addrbook
|
||||||
|
|
||||||
XPIDLSRCS = \
|
XPIDLSRCS = \
|
||||||
nsIAbListener.idl \
|
nsIAbListener.idl \
|
||||||
nsIAbDirectory.idl \
|
|
||||||
nsIAbItem.idl \
|
nsIAbItem.idl \
|
||||||
|
nsIAbCollection.idl \
|
||||||
nsIAbCard.idl \
|
nsIAbCard.idl \
|
||||||
|
nsIAbDirectory.idl \
|
||||||
nsIAbMDBDirectory.idl \
|
nsIAbMDBDirectory.idl \
|
||||||
nsIAddrDBAnnouncer.idl \
|
nsIAddrDBAnnouncer.idl \
|
||||||
nsIAddrDBListener.idl \
|
nsIAddrDBListener.idl \
|
||||||
|
|
|
@ -0,0 +1,108 @@
|
||||||
|
/* -*- 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
|
||||||
|
* http://www.mozilla.org/MPL/
|
||||||
|
*
|
||||||
|
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||||
|
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||||
|
* for the specific language governing rights and limitations under the
|
||||||
|
* License.
|
||||||
|
*
|
||||||
|
* The Original Code is mozilla.org code.
|
||||||
|
*
|
||||||
|
* The Initial Developer of the Original Code is
|
||||||
|
* Mozilla Messaging Corporation.
|
||||||
|
* Portions created by the Initial Developer are Copyright (C) 2008
|
||||||
|
* the Initial Developer. All Rights Reserved.
|
||||||
|
*
|
||||||
|
* Contributor(s):
|
||||||
|
* Mark Banner <bugzilla@standard8.plus.com>
|
||||||
|
* Joshua Cranmer <Pidgeot18@gmail.com>
|
||||||
|
*
|
||||||
|
* 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 nsIAbCard;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A collection of address book items.
|
||||||
|
*/
|
||||||
|
[scriptable, uuid(e6f97fdb-2e3e-46ad-974d-50f1388953c0)]
|
||||||
|
interface nsIAbCollection : nsIAbItem {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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.
|
||||||
|
*
|
||||||
|
* 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);
|
||||||
|
};
|
|
@ -38,7 +38,7 @@
|
||||||
*
|
*
|
||||||
* ***** END LICENSE BLOCK ***** */
|
* ***** END LICENSE BLOCK ***** */
|
||||||
|
|
||||||
#include "nsISupports.idl"
|
#include "nsIAbCollection.idl"
|
||||||
#include "nsIAbCard.idl"
|
#include "nsIAbCard.idl"
|
||||||
|
|
||||||
interface nsISimpleEnumerator;
|
interface nsISimpleEnumerator;
|
||||||
|
@ -60,8 +60,8 @@ interface nsIMutableArray;
|
||||||
#define kABFileName_CurrentSuffix ".mab" /* v3 address book extension */
|
#define kABFileName_CurrentSuffix ".mab" /* v3 address book extension */
|
||||||
%}
|
%}
|
||||||
|
|
||||||
[scriptable, uuid(1b2637fb-194e-442b-992a-17fe7c068fd4)]
|
[scriptable, uuid(5ee48561-aff9-447c-802d-93384d524f53)]
|
||||||
interface nsIAbDirectory : nsISupports {
|
interface nsIAbDirectory : nsIAbCollection {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The chrome URI to use for bringing up a dialog to edit this directory.
|
* The chrome URI to use for bringing up a dialog to edit this directory.
|
||||||
|
@ -71,21 +71,6 @@ interface nsIAbDirectory : nsISupports {
|
||||||
*/
|
*/
|
||||||
readonly attribute ACString propertiesChromeURI;
|
readonly attribute ACString propertiesChromeURI;
|
||||||
|
|
||||||
// Types of operation
|
|
||||||
// Perform linear reading of directory card
|
|
||||||
// content
|
|
||||||
const long opRead = 0x1;
|
|
||||||
// Perform modification and deletion on a
|
|
||||||
// directories content
|
|
||||||
const long opWrite = 0x2;
|
|
||||||
// Perform searching on a directory card
|
|
||||||
// content via the uri format:
|
|
||||||
// scheme://path?query
|
|
||||||
const long opSearch = 0x4;
|
|
||||||
|
|
||||||
// The supported operations
|
|
||||||
readonly attribute long operations;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The description of the directory. If this directory is not a mailing list,
|
* The description of the directory. If this directory is not a mailing list,
|
||||||
* then setting this attribute will send round a "DirName" update via
|
* then setting this attribute will send round a "DirName" update via
|
||||||
|
@ -164,16 +149,6 @@ interface nsIAbDirectory : nsISupports {
|
||||||
|
|
||||||
void dropCard(in nsIAbCard card, in boolean needToCopyCard);
|
void dropCard(in nsIAbCard card, in boolean needToCopyCard);
|
||||||
|
|
||||||
/**
|
|
||||||
* directory is local (example, mork based) or remote (example, LDAP)
|
|
||||||
*/
|
|
||||||
readonly attribute boolean isRemote;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* directory is secure (as in LDAP over SSL)
|
|
||||||
*/
|
|
||||||
readonly attribute boolean isSecure;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Whether or not the directory should be searched when doing autocomplete,
|
* Whether or not the directory should be searched when doing autocomplete,
|
||||||
* (currently by using GetChildCards); LDAP does not support this in online
|
* (currently by using GetChildCards); LDAP does not support this in online
|
||||||
|
@ -308,45 +283,4 @@ interface nsIAbDirectory : nsISupports {
|
||||||
void setStringValue(in string aName, in ACString aValue);
|
void setStringValue(in string aName, in ACString aValue);
|
||||||
void setLocalizedStringValue(in string aName, in AUTF8String aValue);
|
void setLocalizedStringValue(in string aName, in AUTF8String aValue);
|
||||||
//@}
|
//@}
|
||||||
|
|
||||||
/**
|
|
||||||
* 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.
|
|
||||||
*
|
|
||||||
* If the address book type does not know how to find a card, it will throw
|
|
||||||
* NS_ERROR_NOT_IMPLEMENTED. Core address book types do throw this exception,
|
|
||||||
* so beware when calling this method.
|
|
||||||
*
|
|
||||||
* @param emailAddress The email address to find in either the primary or
|
|
||||||
* secondary email address fields. If email address 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.
|
|
||||||
*/
|
|
||||||
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.
|
|
||||||
*
|
|
||||||
* If the address book type does not know how to do this, it will throw
|
|
||||||
* NS_ERROR_NOT_IMPLEMENTED. Core address book types do throw this exception,
|
|
||||||
* so beware when calling this method.
|
|
||||||
*
|
|
||||||
* 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-senstively.
|
|
||||||
* @result An nsIAbCard if one was found, else returns NULL.
|
|
||||||
*/
|
|
||||||
nsIAbCard getCardFromProperty(in string aProperty, in AUTF8String aValue,
|
|
||||||
in boolean aCaseSensitive);
|
|
||||||
};
|
};
|
||||||
|
|
|
@ -120,7 +120,7 @@ function OnLoadNewCard()
|
||||||
if (parentURI)
|
if (parentURI)
|
||||||
gEditCard.selectedAB = parentURI;
|
gEditCard.selectedAB = parentURI;
|
||||||
}
|
}
|
||||||
else if (directory.operations & directory.opWrite)
|
else if (!directory.readOnly)
|
||||||
gEditCard.selectedAB = window.arguments[0].selectedAB;
|
gEditCard.selectedAB = window.arguments[0].selectedAB;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -266,7 +266,7 @@ function OnLoadEditCard()
|
||||||
var abURI = window.arguments[0].abURI;
|
var abURI = window.arguments[0].abURI;
|
||||||
var directory = GetDirectoryFromURI(abURI);
|
var directory = GetDirectoryFromURI(abURI);
|
||||||
|
|
||||||
if (!(directory.operations & directory.opWrite))
|
if (directory.readOnly)
|
||||||
{
|
{
|
||||||
// Set all the editable vcard fields to read only
|
// Set all the editable vcard fields to read only
|
||||||
for (var i = kVcardFields.length; i-- > 0; )
|
for (var i = kVcardFields.length; i-- > 0; )
|
||||||
|
|
|
@ -98,8 +98,7 @@ var DirPaneController =
|
||||||
// If the directory is a mailing list, and it is read-only, return
|
// If the directory is a mailing list, and it is read-only, return
|
||||||
// false.
|
// false.
|
||||||
var abDir = GetDirectoryFromURI(selectedDir);
|
var abDir = GetDirectoryFromURI(selectedDir);
|
||||||
if (abDir.isMailList &&
|
if (abDir.isMailList && abDir.readOnly)
|
||||||
~abDir.operations & abDir.opWrite)
|
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
// If the selected directory is an ldap directory
|
// If the selected directory is an ldap directory
|
||||||
|
|
|
@ -55,7 +55,7 @@ var abResultsPaneObserver = {
|
||||||
var srcDirectory = GetDirectoryFromURI(GetSelectedDirectory());
|
var srcDirectory = GetDirectoryFromURI(GetSelectedDirectory());
|
||||||
// The default allowable actions are copy, move and link, so we need
|
// The default allowable actions are copy, move and link, so we need
|
||||||
// to restrict them here.
|
// to restrict them here.
|
||||||
if ((srcDirectory.operations & srcDirectory.opWrite))
|
if (!srcDirectory.readOnly)
|
||||||
// Only allow copy & move from read-write directories.
|
// Only allow copy & move from read-write directories.
|
||||||
aDragAction.action = Components.interfaces.
|
aDragAction.action = Components.interfaces.
|
||||||
nsIDragService.DRAGDROP_ACTION_COPY |
|
nsIDragService.DRAGDROP_ACTION_COPY |
|
||||||
|
@ -137,7 +137,7 @@ var abDirTreeObserver = {
|
||||||
// e.g. LDAP is readonly currently
|
// e.g. LDAP is readonly currently
|
||||||
var targetDirectory = GetDirectoryFromURI(targetURI);
|
var targetDirectory = GetDirectoryFromURI(targetURI);
|
||||||
|
|
||||||
if (!(targetDirectory.operations & targetDirectory.opWrite))
|
if (targetDirectory.readOnly)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
var dragSession = dragService.getCurrentSession();
|
var dragSession = dragService.getCurrentSession();
|
||||||
|
@ -157,7 +157,7 @@ var abDirTreeObserver = {
|
||||||
var srcDirectory = GetDirectoryFromURI(srcURI);
|
var srcDirectory = GetDirectoryFromURI(srcURI);
|
||||||
|
|
||||||
// Only allow copy from read-only directories.
|
// Only allow copy from read-only directories.
|
||||||
if (!(srcDirectory.operations & srcDirectory.opWrite) &&
|
if (srcDirectory.readOnly &&
|
||||||
dragSession.dragAction != Components.interfaces.
|
dragSession.dragAction != Components.interfaces.
|
||||||
nsIDragService.DRAGDROP_ACTION_COPY)
|
nsIDragService.DRAGDROP_ACTION_COPY)
|
||||||
return false;
|
return false;
|
||||||
|
|
|
@ -220,7 +220,7 @@ function OnLoadNewMailList()
|
||||||
selectedAB = parentURI;
|
selectedAB = parentURI;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (!(directory.operations & directory.opWrite)) {
|
else if (directory.readOnly) {
|
||||||
selectedAB = kPersonalAddressbookURI;
|
selectedAB = kPersonalAddressbookURI;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -309,7 +309,7 @@ function OnLoadEditList()
|
||||||
|
|
||||||
// Is this directory read-only? If so, we now need to set all the fields to
|
// Is this directory read-only? If so, we now need to set all the fields to
|
||||||
// read-only.
|
// read-only.
|
||||||
if (~gEditList.operations & gEditList.opWrite) {
|
if (gEditList.readOnly) {
|
||||||
const kMailListFields = [ 'ListName', 'ListNickName', 'ListDescription' ];
|
const kMailListFields = [ 'ListName', 'ListNickName', 'ListDescription' ];
|
||||||
|
|
||||||
for (var i = 0; i < kMailListFields.length; ++i)
|
for (var i = 0; i < kMailListFields.length; ++i)
|
||||||
|
|
|
@ -381,7 +381,7 @@ var ResultsPaneController =
|
||||||
var enabled = false;
|
var enabled = false;
|
||||||
if (gAbView && gAbView.selection) {
|
if (gAbView && gAbView.selection) {
|
||||||
if (gAbView.directory)
|
if (gAbView.directory)
|
||||||
enabled = gAbView.directory.operations & gAbView.directory.opWrite;
|
enabled = !gAbView.directory.readOnly;
|
||||||
numSelected = gAbView.selection.count;
|
numSelected = gAbView.selection.count;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|
|
@ -183,11 +183,10 @@
|
||||||
<parameter name="ab"/>
|
<parameter name="ab"/>
|
||||||
<body><![CDATA[
|
<body><![CDATA[
|
||||||
// This condition is used for instance when creating cards
|
// This condition is used for instance when creating cards
|
||||||
if (this.getAttribute("writable") == "true" &&
|
if (this.getAttribute("writable") == "true" && ab.readOnly)
|
||||||
!(ab.operations & Components.interfaces.nsIAbDirectory.opWrite))
|
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
// This condition is used for isntance when creating mailing lists
|
// This condition is used for instance when creating mailing lists
|
||||||
if (this.getAttribute("supportsmaillists") == "true" &&
|
if (this.getAttribute("supportsmaillists") == "true" &&
|
||||||
!ab.supportsMailingLists)
|
!ab.supportsMailingLists)
|
||||||
return false;
|
return false;
|
||||||
|
|
|
@ -77,25 +77,19 @@ nsAbDirProperty::~nsAbDirProperty(void)
|
||||||
|
|
||||||
NS_IMPL_ISUPPORTS1(nsAbDirProperty,nsIAbDirectory)
|
NS_IMPL_ISUPPORTS1(nsAbDirProperty,nsIAbDirectory)
|
||||||
|
|
||||||
|
NS_IMETHODIMP nsAbDirProperty::GenerateName(PRInt32 aGenerateFormat,
|
||||||
|
nsIStringBundle *aBundle,
|
||||||
|
nsAString &name)
|
||||||
|
{
|
||||||
|
return GetDirName(name);
|
||||||
|
}
|
||||||
|
|
||||||
NS_IMETHODIMP nsAbDirProperty::GetPropertiesChromeURI(nsACString &aResult)
|
NS_IMETHODIMP nsAbDirProperty::GetPropertiesChromeURI(nsACString &aResult)
|
||||||
{
|
{
|
||||||
aResult.AssignLiteral("chrome://messenger/content/addressbook/abAddressBookNameDialog.xul");
|
aResult.AssignLiteral("chrome://messenger/content/addressbook/abAddressBookNameDialog.xul");
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
NS_IMETHODIMP nsAbDirProperty::GetOperations(PRInt32 *aOperations)
|
|
||||||
{
|
|
||||||
// Default is to support all operations.
|
|
||||||
// Inheriting implementations may override
|
|
||||||
// to reduce supported operations
|
|
||||||
NS_ENSURE_ARG_POINTER(aOperations);
|
|
||||||
*aOperations = nsIAbDirectory::opRead |
|
|
||||||
nsIAbDirectory::opWrite |
|
|
||||||
nsIAbDirectory::opSearch;
|
|
||||||
|
|
||||||
return NS_OK;
|
|
||||||
}
|
|
||||||
|
|
||||||
NS_IMETHODIMP nsAbDirProperty::GetDirName(nsAString &aDirName)
|
NS_IMETHODIMP nsAbDirProperty::GetDirName(nsAString &aDirName)
|
||||||
{
|
{
|
||||||
if (m_DirPrefId.IsEmpty())
|
if (m_DirPrefId.IsEmpty())
|
||||||
|
@ -330,6 +324,15 @@ NS_IMETHODIMP nsAbDirProperty::GetSupportsMailingLists(PRBool *aSupportsMailings
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
NS_IMETHODIMP nsAbDirProperty::GetReadOnly(PRBool *aReadOnly)
|
||||||
|
{
|
||||||
|
NS_ENSURE_ARG_POINTER(aReadOnly);
|
||||||
|
// Default is that we are writable. Any implementation that is read-only must
|
||||||
|
// override this method.
|
||||||
|
*aReadOnly = PR_FALSE;
|
||||||
|
return NS_OK;
|
||||||
|
}
|
||||||
|
|
||||||
NS_IMETHODIMP nsAbDirProperty::GetIsRemote(PRBool *aIsRemote)
|
NS_IMETHODIMP nsAbDirProperty::GetIsRemote(PRBool *aIsRemote)
|
||||||
{
|
{
|
||||||
NS_ENSURE_ARG_POINTER(aIsRemote);
|
NS_ENSURE_ARG_POINTER(aIsRemote);
|
||||||
|
|
|
@ -65,8 +65,10 @@ public:
|
||||||
nsAbDirProperty(void);
|
nsAbDirProperty(void);
|
||||||
virtual ~nsAbDirProperty(void);
|
virtual ~nsAbDirProperty(void);
|
||||||
|
|
||||||
NS_DECL_ISUPPORTS
|
NS_DECL_ISUPPORTS
|
||||||
NS_DECL_NSIABDIRECTORY
|
NS_DECL_NSIABITEM
|
||||||
|
NS_DECL_NSIABCOLLECTION
|
||||||
|
NS_DECL_NSIABDIRECTORY
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -138,34 +138,6 @@ NS_IMETHODIMP nsAbLDAPDirectory::GetURI(nsACString &aURI)
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
NS_IMETHODIMP nsAbLDAPDirectory::GetOperations(PRInt32 *aOperations)
|
|
||||||
{
|
|
||||||
*aOperations = nsIAbDirectory::opSearch;
|
|
||||||
|
|
||||||
#ifdef MOZ_EXPERIMENTAL_WRITEABLE_LDAP
|
|
||||||
PRBool readOnly;
|
|
||||||
nsresult rv = GetBoolValue("readonly", PR_FALSE, &readOnly);
|
|
||||||
NS_ENSURE_SUCCESS(rv, rv);
|
|
||||||
|
|
||||||
if (readOnly)
|
|
||||||
return NS_OK;
|
|
||||||
|
|
||||||
// when online, we'll allow writing as well
|
|
||||||
PRBool offline;
|
|
||||||
nsCOMPtr <nsIIOService> ioService =
|
|
||||||
do_GetService(NS_IOSERVICE_CONTRACTID, &rv);
|
|
||||||
NS_ENSURE_SUCCESS(rv,rv);
|
|
||||||
|
|
||||||
rv = ioService->GetOffline(&offline);
|
|
||||||
NS_ENSURE_SUCCESS(rv,rv);
|
|
||||||
|
|
||||||
if (!offline)
|
|
||||||
*aOperations |= nsIAbDirectory::opWrite;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
return NS_OK;
|
|
||||||
}
|
|
||||||
|
|
||||||
NS_IMETHODIMP nsAbLDAPDirectory::GetChildNodes(nsISimpleEnumerator* *aResult)
|
NS_IMETHODIMP nsAbLDAPDirectory::GetChildNodes(nsISimpleEnumerator* *aResult)
|
||||||
{
|
{
|
||||||
return NS_NewEmptyEnumerator(aResult);
|
return NS_NewEmptyEnumerator(aResult);
|
||||||
|
@ -457,6 +429,36 @@ NS_IMETHODIMP nsAbLDAPDirectory::GetSupportsMailingLists(PRBool *aSupportsMailin
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
NS_IMETHODIMP nsAbLDAPDirectory::GetReadOnly(PRBool *aReadOnly)
|
||||||
|
{
|
||||||
|
NS_ENSURE_ARG_POINTER(aReadOnly);
|
||||||
|
|
||||||
|
*aReadOnly = PR_TRUE;
|
||||||
|
|
||||||
|
#ifdef MOZ_EXPERIMENTAL_WRITEABLE_LDAP
|
||||||
|
PRBool readOnly;
|
||||||
|
nsresult rv = GetBoolValue("readonly", PR_FALSE, &readOnly);
|
||||||
|
NS_ENSURE_SUCCESS(rv, rv);
|
||||||
|
|
||||||
|
if (readOnly)
|
||||||
|
return NS_OK;
|
||||||
|
|
||||||
|
// when online, we'll allow writing as well
|
||||||
|
PRBool offline;
|
||||||
|
nsCOMPtr <nsIIOService> ioService =
|
||||||
|
do_GetService(NS_IOSERVICE_CONTRACTID, &rv);
|
||||||
|
NS_ENSURE_SUCCESS(rv,rv);
|
||||||
|
|
||||||
|
rv = ioService->GetOffline(&offline);
|
||||||
|
NS_ENSURE_SUCCESS(rv,rv);
|
||||||
|
|
||||||
|
if (!offline)
|
||||||
|
*aReadOnly = PR_FALSE;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
return NS_OK;
|
||||||
|
}
|
||||||
|
|
||||||
NS_IMETHODIMP nsAbLDAPDirectory::GetIsRemote(PRBool *aIsRemote)
|
NS_IMETHODIMP nsAbLDAPDirectory::GetIsRemote(PRBool *aIsRemote)
|
||||||
{
|
{
|
||||||
NS_ENSURE_ARG_POINTER(aIsRemote);
|
NS_ENSURE_ARG_POINTER(aIsRemote);
|
||||||
|
|
|
@ -69,11 +69,11 @@ public:
|
||||||
// nsIAbDirectory methods
|
// nsIAbDirectory methods
|
||||||
NS_IMETHOD GetPropertiesChromeURI(nsACString &aResult);
|
NS_IMETHOD GetPropertiesChromeURI(nsACString &aResult);
|
||||||
NS_IMETHOD GetURI(nsACString &aURI);
|
NS_IMETHOD GetURI(nsACString &aURI);
|
||||||
NS_IMETHOD GetOperations(PRInt32 *aOperations);
|
|
||||||
NS_IMETHOD GetChildNodes(nsISimpleEnumerator* *result);
|
NS_IMETHOD GetChildNodes(nsISimpleEnumerator* *result);
|
||||||
NS_IMETHOD GetChildCards(nsISimpleEnumerator* *result);
|
NS_IMETHOD GetChildCards(nsISimpleEnumerator* *result);
|
||||||
NS_IMETHOD HasCard(nsIAbCard *cards, PRBool *hasCard);
|
NS_IMETHOD HasCard(nsIAbCard *cards, PRBool *hasCard);
|
||||||
NS_IMETHOD GetSupportsMailingLists(PRBool *aSupportsMailingsLists);
|
NS_IMETHOD GetSupportsMailingLists(PRBool *aSupportsMailingsLists);
|
||||||
|
NS_IMETHOD GetReadOnly(PRBool *aReadOnly);
|
||||||
NS_IMETHOD GetIsRemote(PRBool *aIsRemote);
|
NS_IMETHOD GetIsRemote(PRBool *aIsRemote);
|
||||||
NS_IMETHOD GetIsSecure(PRBool *aIsRemote);
|
NS_IMETHOD GetIsSecure(PRBool *aIsRemote);
|
||||||
NS_IMETHOD UseForAutocomplete(const nsACString &aIdentityKey, PRBool *aResult);
|
NS_IMETHOD UseForAutocomplete(const nsACString &aIdentityKey, PRBool *aResult);
|
||||||
|
|
|
@ -93,7 +93,7 @@ public:
|
||||||
NS_IMETHOD Init(const char *aUri);
|
NS_IMETHOD Init(const char *aUri);
|
||||||
|
|
||||||
// nsAbDirProperty methods
|
// nsAbDirProperty methods
|
||||||
NS_IMETHOD GetOperations(PRInt32 *aOperations);
|
NS_IMETHOD GetReadOnly(PRBool *aReadOnly);
|
||||||
NS_IMETHOD GetChildCards(nsISimpleEnumerator **aCards);
|
NS_IMETHOD GetChildCards(nsISimpleEnumerator **aCards);
|
||||||
NS_IMETHOD GetChildNodes(nsISimpleEnumerator **aNodes);
|
NS_IMETHOD GetChildNodes(nsISimpleEnumerator **aNodes);
|
||||||
NS_IMETHOD HasCard(nsIAbCard *aCard, PRBool *aHasCard);
|
NS_IMETHOD HasCard(nsIAbCard *aCard, PRBool *aHasCard);
|
||||||
|
|
|
@ -522,11 +522,11 @@ nsAbOSXDirectory::GetURI(nsACString &aURI)
|
||||||
}
|
}
|
||||||
|
|
||||||
NS_IMETHODIMP
|
NS_IMETHODIMP
|
||||||
nsAbOSXDirectory::GetOperations(PRInt32 *aOperations)
|
nsAbOSXDirectory::GetReadOnly(PRBool *aReadOnly)
|
||||||
{
|
{
|
||||||
*aOperations = nsIAbDirectory::opRead |
|
NS_ENSURE_ARG_POINTER(aReadOnly);
|
||||||
nsIAbDirectory::opSearch;
|
|
||||||
|
*aReadOnly = PR_TRUE;
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -494,11 +494,11 @@ nsresult
|
||||||
nsAbDirectoryDataSource::createDirectoryIsWriteableNode(nsIAbDirectory* directory,
|
nsAbDirectoryDataSource::createDirectoryIsWriteableNode(nsIAbDirectory* directory,
|
||||||
nsIRDFNode **target)
|
nsIRDFNode **target)
|
||||||
{
|
{
|
||||||
PRBool isWriteable;
|
PRBool isReadOnly;
|
||||||
nsresult rv = directory->GetOperations(&isWriteable);
|
nsresult rv = directory->GetReadOnly(&isReadOnly);
|
||||||
NS_ENSURE_SUCCESS(rv, rv);
|
NS_ENSURE_SUCCESS(rv, rv);
|
||||||
|
|
||||||
NS_IF_ADDREF(*target = ((isWriteable & nsIAbDirectory::opWrite) ? kTrueLiteral : kFalseLiteral));
|
NS_IF_ADDREF(*target = (isReadOnly ? kFalseLiteral : kTrueLiteral));
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -19,9 +19,7 @@ var kPABData =
|
||||||
dirName: "Personal Address Book",
|
dirName: "Personal Address Book",
|
||||||
dirType: 2,
|
dirType: 2,
|
||||||
dirPrefID: "ldap_2.servers.pab",
|
dirPrefID: "ldap_2.servers.pab",
|
||||||
operations: Components.interfaces.nsIAbDirectory.opRead |
|
readOnly: false,
|
||||||
Components.interfaces.nsIAbDirectory.opWrite |
|
|
||||||
Components.interfaces.nsIAbDirectory.opSearch,
|
|
||||||
position: 1
|
position: 1
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -33,9 +31,7 @@ var kCABData =
|
||||||
dirName: "Collected Addresses",
|
dirName: "Collected Addresses",
|
||||||
dirType: 2,
|
dirType: 2,
|
||||||
dirPrefID: "ldap_2.servers.history",
|
dirPrefID: "ldap_2.servers.history",
|
||||||
operations: Components.interfaces.nsIAbDirectory.opRead |
|
readOnly: false,
|
||||||
Components.interfaces.nsIAbDirectory.opWrite |
|
|
||||||
Components.interfaces.nsIAbDirectory.opSearch,
|
|
||||||
position: 2
|
position: 2
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -47,8 +43,7 @@ var kOSXData =
|
||||||
dirName: "Mac OS X Address Book",
|
dirName: "Mac OS X Address Book",
|
||||||
dirType: 3,
|
dirType: 3,
|
||||||
dirPrefID: "ldap_2.servers.osx",
|
dirPrefID: "ldap_2.servers.osx",
|
||||||
operations: Components.interfaces.nsIAbDirectory.opRead |
|
readOnly: true,
|
||||||
Components.interfaces.nsIAbDirectory.opSearch,
|
|
||||||
position: 1
|
position: 1
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -44,8 +44,9 @@ function check_ab(abConfig) {
|
||||||
|
|
||||||
// Test - Check attributes
|
// Test - Check attributes
|
||||||
|
|
||||||
|
do_check_eq(AB.generateName(0), abConfig.dirName);
|
||||||
do_check_eq(AB.propertiesChromeURI, kNormalPropertiesURI);
|
do_check_eq(AB.propertiesChromeURI, kNormalPropertiesURI);
|
||||||
do_check_eq(AB.operations, abConfig.operations);
|
do_check_eq(AB.readOnly, abConfig.readOnly);
|
||||||
do_check_eq(AB.dirName, abConfig.dirName);
|
do_check_eq(AB.dirName, abConfig.dirName);
|
||||||
do_check_eq(AB.dirType, abConfig.dirType);
|
do_check_eq(AB.dirType, abConfig.dirType);
|
||||||
do_check_eq(AB.fileName, abConfig.fileName);
|
do_check_eq(AB.fileName, abConfig.fileName);
|
||||||
|
|
|
@ -26,6 +26,7 @@ function run_test() {
|
||||||
// Test - Check various fields
|
// Test - Check various fields
|
||||||
do_check_eq(abDir.dirName, "test");
|
do_check_eq(abDir.dirName, "test");
|
||||||
do_check_eq(abDir.lDAPURL.spec, kLDAPTestSpec);
|
do_check_eq(abDir.lDAPURL.spec, kLDAPTestSpec);
|
||||||
|
do_check_true(abDir.readOnly);
|
||||||
|
|
||||||
// Test - Write a UTF-8 Auth DN and check it
|
// Test - Write a UTF-8 Auth DN and check it
|
||||||
abDir.authDn = "test\u00D0";
|
abDir.authDn = "test\u00D0";
|
||||||
|
|
|
@ -4652,13 +4652,13 @@ nsMsgCompose::CheckAndPopulateRecipients(PRBool aPopulateMailList,
|
||||||
if (NS_SUCCEEDED(rv))
|
if (NS_SUCCEEDED(rv))
|
||||||
recipient.mProcessed = PR_TRUE;
|
recipient.mProcessed = PR_TRUE;
|
||||||
|
|
||||||
PRInt32 isWriteable;
|
PRBool readOnly;
|
||||||
rv = abDirectory->GetOperations(&isWriteable);
|
rv = abDirectory->GetReadOnly(&readOnly);
|
||||||
NS_ENSURE_SUCCESS(rv,rv);
|
NS_ENSURE_SUCCESS(rv,rv);
|
||||||
|
|
||||||
// bump the popularity index for this card since we are about to send e-mail to it
|
// bump the popularity index for this card since we are about to send e-mail to it
|
||||||
PRUint32 popularityIndex = 0;
|
PRUint32 popularityIndex = 0;
|
||||||
if ((isWriteable & nsIAbDirectory::opWrite) && NS_SUCCEEDED(existingCard->GetPropertyAsUint32(
|
if (!readOnly && NS_SUCCEEDED(existingCard->GetPropertyAsUint32(
|
||||||
kPopularityIndexProperty, &popularityIndex)))
|
kPopularityIndexProperty, &popularityIndex)))
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
Загрузка…
Ссылка в новой задаче