fix for #119932. delete addressbook is failing. while I'm here,

remove unnecessary dependency on the DOM.  the addressbook
backend doesn't need to be dependent on nsIDOMXULElement and
nsIDOMNodeList.  r/sr=bienvenu
This commit is contained in:
sspitzer%netscape.com 2002-01-14 19:50:34 +00:00
Родитель 11c39d25a6
Коммит 39a8a0e9ca
3 изменённых файлов: 12 добавлений и 57 удалений

Просмотреть файл

@ -41,8 +41,6 @@
#include "nsISupportsArray.idl"
interface nsIDOMWindowInternal;
interface nsIDOMXULElement;
interface nsIDOMNodeList;
interface nsIFileSpec;
interface nsIAbDirectory;
@ -50,7 +48,7 @@ interface nsIAbDirectory;
interface nsIAddressBook : nsISupports
{
void newAddressBook(in nsIRDFCompositeDataSource db, in unsigned long prefCount,[array, size_is(prefCount)] in string prefName, [array, size_is(prefCount)] in wstring prefValue);
void deleteAddressBooks(in nsIRDFCompositeDataSource db, in nsISupportsArray parentDir, in nsIDOMNodeList node);
void deleteAddressBooks(in nsIRDFCompositeDataSource db, in nsISupportsArray parentDir, in nsISupportsArray aResourceArray);
void setDocShellWindow(in nsIDOMWindowInternal win);
void exportAddressBook(in nsIAbDirectory aDirectory);
void convertLDIFtoMAB(in nsIFileSpec fileSpec, in boolean migrating, in nsIAddrDatabase db, in boolean bStoreLocAsHome, in boolean bImportingComm4x);

Просмотреть файл

@ -415,7 +415,12 @@ function AbDeleteDirectory()
if (!window.confirm(confirmDeleteMessage))
return;
top.addressbook.deleteAddressBooks(dirTree.database, parentArray, dirTree.selectedItems);
var resourceArray = Components.classes["@mozilla.org/supports-array;1"].createInstance(Components.interfaces.nsISupportsArray);
var selectedABResource = GetDirectoryFromURI(selectedABURI).QueryInterface(Components.interfaces.nsIRDFResource);
resourceArray.AppendElement(selectedABResource);
top.addressbook.deleteAddressBooks(dirTree.database, parentArray, resourceArray);
SelectFirstAddressBook();
}

Просмотреть файл

@ -55,8 +55,6 @@
#include "prprf.h"
#include "nsCOMPtr.h"
#include "nsIDOMXULElement.h"
#include "nsIDOMNodeList.h"
#include "nsIRDFCompositeDataSource.h"
#include "nsIRDFResource.h"
#include "nsRDFResource.h"
@ -127,46 +125,6 @@ static const char *AB_COLUMN_ARRAY[] = {
kNotesColumn
};
static nsresult ConvertDOMListToResourceArray(nsIDOMNodeList *nodeList, nsISupportsArray **resourceArray)
{
nsresult rv = NS_OK;
PRUint32 listLength;
nsIDOMNode *node;
nsIDOMXULElement *xulElement;
nsIRDFResource *resource;
if(!resourceArray)
return NS_ERROR_NULL_POINTER;
if(NS_FAILED(rv = nodeList->GetLength(&listLength)))
return rv;
if(NS_FAILED(NS_NewISupportsArray(resourceArray)))
{
return NS_ERROR_OUT_OF_MEMORY;
}
for(PRUint32 i = 0; i < listLength; i++)
{
if(NS_FAILED(nodeList->Item(i, &node)))
return rv;
if(NS_SUCCEEDED(rv = node->QueryInterface(NS_GET_IID(nsIDOMXULElement), (void**)&xulElement)))
{
if(NS_SUCCEEDED(rv = xulElement->GetResource(&resource)))
{
(*resourceArray)->AppendElement(resource);
NS_RELEASE(resource);
}
NS_RELEASE(xulElement);
}
NS_RELEASE(node);
}
return rv;
}
//
// nsAddressBook
//
@ -210,19 +168,13 @@ NS_IMETHODIMP nsAddressBook::NewAddressBook
}
NS_IMETHODIMP nsAddressBook::DeleteAddressBooks
(nsIRDFCompositeDataSource* db, nsISupportsArray *parentDir, nsIDOMNodeList *nodeList)
(nsIRDFCompositeDataSource* db, nsISupportsArray *parentDir, nsISupportsArray *aResourceArray)
{
if(!db || !parentDir || !nodeList)
return NS_ERROR_NULL_POINTER;
NS_ENSURE_ARG_POINTER(db);
NS_ENSURE_ARG_POINTER(parentDir);
NS_ENSURE_ARG_POINTER(aResourceArray);
nsresult rv = NS_OK;
nsCOMPtr<nsISupportsArray> resourceArray;
rv = ConvertDOMListToResourceArray(nodeList, getter_AddRefs(resourceArray));
NS_ENSURE_SUCCESS(rv, rv);
DoCommand(db, NC_RDF_DELETE, parentDir, resourceArray);
return rv;
return DoCommand(db, NC_RDF_DELETE, parentDir, aResourceArray);
}
nsresult nsAddressBook::DoCommand(nsIRDFCompositeDataSource* db,