From 2ec29ebf230b915c8e702c4e19216b15d00d255e Mon Sep 17 00:00:00 2001 From: "axel%pike.org" Date: Mon, 2 May 2005 15:41:47 +0000 Subject: [PATCH] bug 290043, Tidy address book code, patch by Mark Banner, r=bienvenu, sr=mscott, a=chofmann git-svn-id: svn://10.0.0.236/trunk@172949 18797224-902f-48f8-a5cc-f745e15eee43 --- .../addrbook/public/nsIAddrDBAnnouncer.idl | 8 +- .../addrbook/public/nsIAddrDBListener.idl | 13 +- .../addrbook/src/nsAbMDBDirectory.cpp | 8 +- .../mailnews/addrbook/src/nsAbRDFResource.cpp | 124 ------------------ .../mailnews/addrbook/src/nsAbRDFResource.h | 77 ----------- .../mailnews/addrbook/src/nsAddrDatabase.cpp | 36 ++--- .../mailnews/addrbook/src/nsAddrDatabase.h | 2 +- 7 files changed, 31 insertions(+), 237 deletions(-) delete mode 100644 mozilla/mailnews/addrbook/src/nsAbRDFResource.cpp delete mode 100644 mozilla/mailnews/addrbook/src/nsAbRDFResource.h diff --git a/mozilla/mailnews/addrbook/public/nsIAddrDBAnnouncer.idl b/mozilla/mailnews/addrbook/public/nsIAddrDBAnnouncer.idl index 22f38f1b007..bb740e709bf 100644 --- a/mozilla/mailnews/addrbook/public/nsIAddrDBAnnouncer.idl +++ b/mozilla/mailnews/addrbook/public/nsIAddrDBAnnouncer.idl @@ -40,17 +40,15 @@ interface nsIAddrDBListener; -[scriptable, uuid(A4186D8A-1DD0-11d3-A303-001083003D0C)] +[scriptable, uuid(0d8fe8e3-ad48-4dbd-b0c2-a1d374e39b93)] interface nsIAddrDBAnnouncer : nsISupports { void addListener(in nsIAddrDBListener listener); void removeListener(in nsIAddrDBListener listener); - void notifyCardAttribChange(in unsigned long abCode, - in nsIAddrDBListener instigator); + void notifyCardAttribChange(in unsigned long abCode); void notifyCardEntryChange (in unsigned long abCode, - in nsIAbCard card, - in nsIAddrDBListener instigator); + in nsIAbCard card); void notifyAnnouncerGoingAway(); }; diff --git a/mozilla/mailnews/addrbook/public/nsIAddrDBListener.idl b/mozilla/mailnews/addrbook/public/nsIAddrDBListener.idl index fd56a7a6403..ffbf3e9b225 100644 --- a/mozilla/mailnews/addrbook/public/nsIAddrDBListener.idl +++ b/mozilla/mailnews/addrbook/public/nsIAddrDBListener.idl @@ -40,17 +40,14 @@ interface nsIAddrDBAnnouncer; -[scriptable, uuid(A4186D89-1DD0-11d3-A303-001083003D0C)] +[scriptable, uuid(96876e1d-50a8-4264-8cd0-953d75d0e81b)] interface nsIAddrDBListener : nsISupports { - void onCardAttribChange(in unsigned long abCode, - in nsIAddrDBListener instigator); + void onCardAttribChange(in unsigned long abCode); void onCardEntryChange (in unsigned long abCode, - in nsIAbCard card, - in nsIAddrDBListener instigator); + in nsIAbCard card); void onListEntryChange (in unsigned long abCode, - in nsIAbDirectory list, - in nsIAddrDBListener instigator); - void onAnnouncerGoingAway(in nsIAddrDBAnnouncer instigator); + in nsIAbDirectory list); + void onAnnouncerGoingAway(); }; diff --git a/mozilla/mailnews/addrbook/src/nsAbMDBDirectory.cpp b/mozilla/mailnews/addrbook/src/nsAbMDBDirectory.cpp index 2e8547d16ef..b522329adb6 100644 --- a/mozilla/mailnews/addrbook/src/nsAbMDBDirectory.cpp +++ b/mozilla/mailnews/addrbook/src/nsAbMDBDirectory.cpp @@ -841,13 +841,13 @@ NS_IMETHODIMP nsAbMDBDirectory::EditMailListToDatabase(const char *uri, nsIAbCar // nsIAddrDBListener methods -NS_IMETHODIMP nsAbMDBDirectory::OnCardAttribChange(PRUint32 abCode, nsIAddrDBListener *instigator) +NS_IMETHODIMP nsAbMDBDirectory::OnCardAttribChange(PRUint32 abCode) { return NS_OK; } NS_IMETHODIMP nsAbMDBDirectory::OnCardEntryChange -(PRUint32 abCode, nsIAbCard *card, nsIAddrDBListener *instigator) +(PRUint32 abCode, nsIAbCard *card) { NS_ENSURE_ARG_POINTER(card); nsCOMPtr cardSupports(do_QueryInterface(card)); @@ -873,7 +873,7 @@ NS_IMETHODIMP nsAbMDBDirectory::OnCardEntryChange } NS_IMETHODIMP nsAbMDBDirectory::OnListEntryChange -(PRUint32 abCode, nsIAbDirectory *list, nsIAddrDBListener *instigator) +(PRUint32 abCode, nsIAbDirectory *list) { nsresult rv = NS_OK; @@ -898,7 +898,7 @@ NS_IMETHODIMP nsAbMDBDirectory::OnListEntryChange return rv; } -NS_IMETHODIMP nsAbMDBDirectory::OnAnnouncerGoingAway(nsIAddrDBAnnouncer *instigator) +NS_IMETHODIMP nsAbMDBDirectory::OnAnnouncerGoingAway() { if (mDatabase) mDatabase->RemoveListener(this); diff --git a/mozilla/mailnews/addrbook/src/nsAbRDFResource.cpp b/mozilla/mailnews/addrbook/src/nsAbRDFResource.cpp deleted file mode 100644 index b803b453ddd..00000000000 --- a/mozilla/mailnews/addrbook/src/nsAbRDFResource.cpp +++ /dev/null @@ -1,124 +0,0 @@ -/* -*- 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 - * Netscape Communications Corporation. - * Portions created by the Initial Developer are Copyright (C) 1998 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * - * 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 "nsAbRDFResource.h" -#include "nsIRDFService.h" -#include "nsIServiceManager.h" -#include "nsRDFCID.h" -#include "nsAbBaseCID.h" -#include "prmem.h" - -#include "nsAddrDatabase.h" -#include "nsIAddrBookSession.h" - -nsAbRDFResource::nsAbRDFResource(void) -{ - mDatabase = nsnull; -} - -nsAbRDFResource::~nsAbRDFResource(void) -{ - if (mDatabase) - { - mDatabase->RemoveListener(this); - mDatabase->Close(PR_TRUE); - mDatabase = nsnull; - } -} - -NS_IMPL_ISUPPORTS_INHERITED1(nsAbRDFResource, nsRDFResource, nsIAddrDBListener) - -//////////////////////////////////////////////////////////////////////////////// - -NS_IMETHODIMP nsAbRDFResource::OnCardAttribChange(PRUint32 abCode, nsIAddrDBListener *instigator) -{ - return NS_OK; -} - -NS_IMETHODIMP nsAbRDFResource::OnCardEntryChange -(PRUint32 abCode, nsIAbCard *card, nsIAddrDBListener *instigator) -{ - return NS_OK; -} - -NS_IMETHODIMP nsAbRDFResource::OnListEntryChange -(PRUint32 abCode, nsIAbDirectory *list, nsIAddrDBListener *instigator) -{ - return NS_OK; -} - -NS_IMETHODIMP nsAbRDFResource::OnAnnouncerGoingAway(nsIAddrDBAnnouncer *instigator) -{ - return NS_OK; -} - -nsresult nsAbRDFResource::GetAbDatabase() -{ - nsresult rv = NS_OK; - if (!mDatabase && mURI) - { - nsFileSpec* dbPath = nsnull; - - nsCOMPtr abSession = - do_GetService(NS_ADDRBOOKSESSION_CONTRACTID, &rv); - if(NS_SUCCEEDED(rv)) - abSession->GetUserProfileDirectory(&dbPath); - - NS_ConvertUTF8toUCS2 file(&(mURI[kMDBDirectoryRootLen])); - PRInt32 pos = file.Find("/"); - if (pos != -1) - file.Truncate(pos); - (*dbPath) += file; - - nsCOMPtr addrDBFactory = - do_GetService(NS_ADDRDATABASE_CONTRACTID, &rv); - - if (NS_SUCCEEDED(rv) && addrDBFactory) - rv = addrDBFactory->Open(dbPath, PR_TRUE, getter_AddRefs(mDatabase), PR_TRUE); - - if (mDatabase) - mDatabase->AddListener(this); - - delete dbPath; - - return NS_OK; - } - if (!mDatabase) - return NS_ERROR_NULL_POINTER; - return NS_OK; -} - diff --git a/mozilla/mailnews/addrbook/src/nsAbRDFResource.h b/mozilla/mailnews/addrbook/src/nsAbRDFResource.h deleted file mode 100644 index f4f374a8099..00000000000 --- a/mozilla/mailnews/addrbook/src/nsAbRDFResource.h +++ /dev/null @@ -1,77 +0,0 @@ -/* -*- 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 - * Netscape Communications Corporation. - * Portions created by the Initial Developer are Copyright (C) 1998 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * - * 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 ***** */ - -/******************************************************************************************************** - - Interface for representing Address Book Directory - -*********************************************************************************************************/ - -#ifndef nsAbRDFResource_h__ -#define nsAbRDFResource_h__ - -#include "nsRDFResource.h" -#include "nsIAbCard.h" -#include "nsIAbDirectory.h" -#include "nsISupportsArray.h" -#include "nsCOMPtr.h" -#include "nsDirPrefs.h" -#include "nsIAddrDatabase.h" -#include "nsIAddrDBListener.h" - - /* - * Address Book RDF Resources and DB listener - */ - -class nsAbRDFResource: public nsRDFResource, public nsIAddrDBListener -{ -public: - nsAbRDFResource(void); - virtual ~nsAbRDFResource(void); - - NS_DECL_ISUPPORTS_INHERITED - NS_DECL_NSIADDRDBLISTENER - -protected: - - nsresult GetAbDatabase(); - - nsCOMPtr mDatabase; - -}; - -#endif diff --git a/mozilla/mailnews/addrbook/src/nsAddrDatabase.cpp b/mozilla/mailnews/addrbook/src/nsAddrDatabase.cpp index c70c7596cf7..91209db634d 100644 --- a/mozilla/mailnews/addrbook/src/nsAddrDatabase.cpp +++ b/mozilla/mailnews/addrbook/src/nsAddrDatabase.cpp @@ -269,7 +269,7 @@ NS_IMETHODIMP nsAddrDatabase::RemoveListener(nsIAddrDBListener *listener) return NS_ERROR_FAILURE; } -NS_IMETHODIMP nsAddrDatabase::NotifyCardAttribChange(PRUint32 abCode, nsIAddrDBListener *instigator) +NS_IMETHODIMP nsAddrDatabase::NotifyCardAttribChange(PRUint32 abCode) { if (!m_ChangeListeners) return NS_OK; @@ -279,13 +279,13 @@ NS_IMETHODIMP nsAddrDatabase::NotifyCardAttribChange(PRUint32 abCode, nsIAddrDBL nsIAddrDBListener *changeListener = (nsIAddrDBListener *) m_ChangeListeners->ElementAt(i); - nsresult rv = changeListener->OnCardAttribChange(abCode, instigator); + nsresult rv = changeListener->OnCardAttribChange(abCode); NS_ENSURE_SUCCESS(rv, rv); } return NS_OK; } -NS_IMETHODIMP nsAddrDatabase::NotifyCardEntryChange(PRUint32 abCode, nsIAbCard *card, nsIAddrDBListener *instigator) +NS_IMETHODIMP nsAddrDatabase::NotifyCardEntryChange(PRUint32 abCode, nsIAbCard *card) { if (!m_ChangeListeners) return NS_OK; @@ -298,7 +298,7 @@ NS_IMETHODIMP nsAddrDatabase::NotifyCardEntryChange(PRUint32 abCode, nsIAbCard * if (changeListener) { - nsresult rv = changeListener->OnCardEntryChange(abCode, card, instigator); + nsresult rv = changeListener->OnCardEntryChange(abCode, card); NS_ENSURE_SUCCESS(rv, rv); } else @@ -308,7 +308,7 @@ NS_IMETHODIMP nsAddrDatabase::NotifyCardEntryChange(PRUint32 abCode, nsIAbCard * return NS_OK; } -nsresult nsAddrDatabase::NotifyListEntryChange(PRUint32 abCode, nsIAbDirectory *dir, nsIAddrDBListener *instigator) +nsresult nsAddrDatabase::NotifyListEntryChange(PRUint32 abCode, nsIAbDirectory *dir) { if (!m_ChangeListeners) return NS_OK; @@ -320,7 +320,7 @@ nsresult nsAddrDatabase::NotifyListEntryChange(PRUint32 abCode, nsIAbDirectory * nsIAddrDBListener *changeListener = (nsIAddrDBListener *) m_ChangeListeners->ElementAt(i); - nsresult rv = changeListener->OnListEntryChange(abCode, dir, instigator); + nsresult rv = changeListener->OnListEntryChange(abCode, dir); NS_ENSURE_SUCCESS(rv, rv); } return NS_OK; @@ -339,7 +339,7 @@ NS_IMETHODIMP nsAddrDatabase::NotifyAnnouncerGoingAway(void) nsIAddrDBListener *changeListener = (nsIAddrDBListener *) m_ChangeListeners->ElementAt(i); - nsresult rv = changeListener->OnAnnouncerGoingAway(this); + nsresult rv = changeListener->OnAnnouncerGoingAway(); NS_ENSURE_SUCCESS(rv, rv); } return NS_OK; @@ -1551,7 +1551,7 @@ NS_IMETHODIMP nsAddrDatabase::CreateNewCardAndAddToDB(nsIAbCard *newCard, PRBool // do notification if (notify) { - NotifyCardEntryChange(AB_NotifyInserted, newCard, NULL); + NotifyCardEntryChange(AB_NotifyInserted, newCard); } return rv; } @@ -1631,7 +1631,7 @@ NS_IMETHODIMP nsAddrDatabase::CreateNewListCardAndAddToDB(nsIAbDirectory *aList, addressList->AppendElement(newCard); if (notify) - NotifyCardEntryChange(AB_NotifyInserted, newCard, nsnull); + NotifyCardEntryChange(AB_NotifyInserted, newCard); return rv; } @@ -1683,13 +1683,13 @@ NS_IMETHODIMP nsAddrDatabase::AddListCardColumnsToRow NS_IF_ADDREF(*pNewCard = newCard); if (cardWasAdded) { - NotifyCardEntryChange(AB_NotifyInserted, newCard, nsnull); + NotifyCardEntryChange(AB_NotifyInserted, newCard); } else if (!aInMailingList) { - NotifyCardEntryChange(AB_NotifyInserted, pCard, nsnull); + NotifyCardEntryChange(AB_NotifyInserted, pCard); } else { - NotifyCardEntryChange(AB_NotifyPropertyChanged, pCard, nsnull); + NotifyCardEntryChange(AB_NotifyPropertyChanged, pCard); } //add a column with address row id to the list row @@ -1853,7 +1853,7 @@ NS_IMETHODIMP nsAddrDatabase::CreateMailListAndAddToDB(nsIAbDirectory *newList, nsCOMPtr listCard; CreateABListCard(listRow, getter_AddRefs(listCard)); - NotifyCardEntryChange(AB_NotifyInserted, listCard, NULL); + NotifyCardEntryChange(AB_NotifyInserted, listCard); NS_RELEASE(listRow); return NS_OK; @@ -1931,7 +1931,7 @@ NS_IMETHODIMP nsAddrDatabase::DeleteCard(nsIAbCard *card, PRBool notify) if (NS_SUCCEEDED(err)) { if (notify) - NotifyCardEntryChange(AB_NotifyDeleted, card, NULL); + NotifyCardEntryChange(AB_NotifyDeleted, card); } else DeleteRowFromDeletedCardsTable(cardRow); @@ -2020,7 +2020,7 @@ NS_IMETHODIMP nsAddrDatabase::DeleteCardFromMailList(nsIAbDirectory *mailList, n err = DeleteCardFromListRow(pListRow, cardRowID); if (NS_SUCCEEDED(err) && aNotify) { - NotifyCardEntryChange(AB_NotifyDeleted, card, NULL); + NotifyCardEntryChange(AB_NotifyDeleted, card); } NS_RELEASE(pListRow); return NS_OK; @@ -2221,7 +2221,7 @@ NS_IMETHODIMP nsAddrDatabase::EditCard(nsIAbCard *card, PRBool notify) NS_ENSURE_SUCCESS(err, err); if (notify) - NotifyCardEntryChange(AB_NotifyPropertyChanged, card, nsnull); + NotifyCardEntryChange(AB_NotifyPropertyChanged, card); return NS_OK; } @@ -2309,10 +2309,10 @@ NS_IMETHODIMP nsAddrDatabase::EditMailList(nsIAbDirectory *mailList, nsIAbCard * if (notify) { - NotifyListEntryChange(AB_NotifyPropertyChanged, mailList, nsnull); + NotifyListEntryChange(AB_NotifyPropertyChanged, mailList); if (listCard) { - NotifyCardEntryChange(AB_NotifyPropertyChanged, listCard, nsnull); + NotifyCardEntryChange(AB_NotifyPropertyChanged, listCard); } } diff --git a/mozilla/mailnews/addrbook/src/nsAddrDatabase.h b/mozilla/mailnews/addrbook/src/nsAddrDatabase.h index 50122a394b3..73a0b778076 100644 --- a/mozilla/mailnews/addrbook/src/nsAddrDatabase.h +++ b/mozilla/mailnews/addrbook/src/nsAddrDatabase.h @@ -356,7 +356,7 @@ protected: nsresult CreateCardFromDeletedCardsTable(nsIMdbRow* cardRow, mdb_id listRowID, nsIAbCard **result); nsresult DeleteCardFromListRow(nsIMdbRow* pListRow, mdb_id cardRowID); void DeleteCardFromAllMailLists(mdb_id cardRowID); - nsresult NotifyListEntryChange(PRUint32 abCode, nsIAbDirectory *dir, nsIAddrDBListener *instigator); + nsresult NotifyListEntryChange(PRUint32 abCode, nsIAbDirectory *dir); nsresult AddLowercaseColumn(nsIMdbRow * row, mdb_token columnToken, const char* utf8String); nsresult GetRowFromAttribute(const char *aName, const char *aUTF8Value, PRBool aCaseInsensitive, nsIMdbRow **aCardRow);