зеркало из https://github.com/mozilla/gecko-dev.git
Fix for bug # 124057. Deleting addressbook from prefs should delete it from the addressbook window
r=rdayal, sr=sspitzer
This commit is contained in:
Родитель
af9cec5090
Коммит
20feb45deb
|
@ -420,7 +420,21 @@ function onAccept()
|
|||
}
|
||||
var am = Components.classes["@mozilla.org/messenger/account-manager;1"]
|
||||
.getService(Components.interfaces.nsIMsgAccountManager);
|
||||
if (am) {
|
||||
if (am) {
|
||||
var RDF, addressbook, addressbookDS;
|
||||
try {
|
||||
// the rdf service
|
||||
RDF = Components.classes["@mozilla.org/rdf/rdf-service;1"].
|
||||
getService(Components.interfaces.nsIRDFService);
|
||||
// get the datasource for the addressdirectory
|
||||
addressbookDS = RDF.GetDataSource("rdf:addressdirectory");
|
||||
addressbook = Components.classes["@mozilla.org/addressbook;1"].
|
||||
createInstance(Components.interfaces.nsIAddressBook);
|
||||
}
|
||||
catch(ex){
|
||||
dump("Failed to get RDF Service or addressbook " + ex + "\n");
|
||||
}
|
||||
|
||||
var allIdentities = am.allIdentities;
|
||||
var identitiesCount = allIdentities.Count();
|
||||
var identityServer = new Array();
|
||||
|
@ -442,7 +456,25 @@ function onAccept()
|
|||
identityServer[j].deleted = true;
|
||||
}
|
||||
}
|
||||
gPrefInt.deleteBranch(gDeletedDirectories[i]);
|
||||
try {
|
||||
// delete the directory
|
||||
var parentArray = Components.classes["@mozilla.org/supports-array;1"].createInstance(Components.interfaces.nsISupportsArray);
|
||||
|
||||
// moz-abdirectory:// is the RDF root to get all types of addressbooks.
|
||||
var parentDir = RDF.GetResource("moz-abdirectory://").QueryInterface(Components.interfaces.nsIAbDirectory);
|
||||
parentArray.AppendElement(parentDir);
|
||||
var resourceArray = Components.classes["@mozilla.org/supports-array;1"].createInstance(Components.interfaces.nsISupportsArray);
|
||||
|
||||
// the RDF resource URI for LDAPDirectory will be moz-abldapdirectory://<prefName>
|
||||
var selectedABURI = "moz-abldapdirectory://" + gDeletedDirectories[i];
|
||||
var selectedABDirectory = RDF.GetResource(selectedABURI).QueryInterface(Components.interfaces.nsIAbDirectory);
|
||||
var selectedABResource = selectedABDirectory.QueryInterface(Components.interfaces.nsIRDFResource);
|
||||
resourceArray.AppendElement(selectedABResource);
|
||||
addressbook.deleteAddressBooks(addressbookDS, parentArray, resourceArray);
|
||||
}
|
||||
catch(ex){
|
||||
dump("Failed to delete the addressbook " + ex + "\n");
|
||||
}
|
||||
}
|
||||
var svc = Components.classes["@mozilla.org/preferences-service;1"]
|
||||
.getService(Components.interfaces.nsIPrefService);
|
||||
|
|
|
@ -48,7 +48,7 @@ interface nsIAbDirectory;
|
|||
interface nsIAddressBook : nsISupports
|
||||
{
|
||||
void newAddressBook(in nsIAbDirectoryProperties aProperties);
|
||||
void deleteAddressBooks(in nsIRDFCompositeDataSource db, in nsISupportsArray parentDir, in nsISupportsArray aResourceArray);
|
||||
void deleteAddressBooks(in nsIRDFDataSource aDS, in nsISupportsArray aParentDir, 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);
|
||||
|
|
|
@ -353,6 +353,14 @@ NS_IMETHODIMP nsAbBSDirectory::DeleteDirectory(nsIAbDirectory *directory)
|
|||
if (!directory)
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
|
||||
// if addressbook is not launched yet mSevers will not be initialized
|
||||
// calling GetChidNodes will initialize mServers
|
||||
if (!mInitialized) {
|
||||
nsCOMPtr<nsIEnumerator> subDirectories;
|
||||
rv = GetChildNodes(getter_AddRefs(subDirectories));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
}
|
||||
|
||||
DIR_Server *server = nsnull;
|
||||
nsVoidKey key((void *)directory);
|
||||
server = (DIR_Server* )mServers.Get (&key);
|
||||
|
|
|
@ -201,16 +201,16 @@ NS_IMETHODIMP nsAddressBook::NewAddressBook(nsIAbDirectoryProperties *aPropertie
|
|||
}
|
||||
|
||||
NS_IMETHODIMP nsAddressBook::DeleteAddressBooks
|
||||
(nsIRDFCompositeDataSource* db, nsISupportsArray *parentDir, nsISupportsArray *aResourceArray)
|
||||
(nsIRDFDataSource* aDS, nsISupportsArray *aParentDir, nsISupportsArray *aResourceArray)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(db);
|
||||
NS_ENSURE_ARG_POINTER(parentDir);
|
||||
NS_ENSURE_ARG_POINTER(aDS);
|
||||
NS_ENSURE_ARG_POINTER(aParentDir);
|
||||
NS_ENSURE_ARG_POINTER(aResourceArray);
|
||||
|
||||
return DoCommand(db, NC_RDF_DELETE, parentDir, aResourceArray);
|
||||
|
||||
return DoCommand(aDS, NC_RDF_DELETE, aParentDir, aResourceArray);
|
||||
}
|
||||
|
||||
nsresult nsAddressBook::DoCommand(nsIRDFCompositeDataSource* db,
|
||||
nsresult nsAddressBook::DoCommand(nsIRDFDataSource* db,
|
||||
const char *command,
|
||||
nsISupportsArray *srcArray,
|
||||
nsISupportsArray *argumentArray)
|
||||
|
|
|
@ -69,7 +69,7 @@ public:
|
|||
CMDLINEHANDLER_REGISTERPROC_DECLS
|
||||
|
||||
protected:
|
||||
nsresult DoCommand(nsIRDFCompositeDataSource *db, const char * command,
|
||||
nsresult DoCommand(nsIRDFDataSource *db, const char * command,
|
||||
nsISupportsArray *srcArray, nsISupportsArray *arguments);
|
||||
nsresult GetAbDatabaseFromFile(char* pDbFile, nsIAddrDatabase **db);
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче