Part of Bug 403256 Make nsIAddressBook a service - rename nsIAddressBook to nsIAbManager (main code parts). r=Neil,sr=bienvenu

This commit is contained in:
bugzilla%standard8.plus.com 2007-12-13 18:12:18 +00:00
Родитель 288aa11125
Коммит 80d688e7c3
18 изменённых файлов: 65 добавлений и 1287 удалений

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

@ -151,8 +151,8 @@ function OnLoadNewCard()
// hide non vcard values
HideNonVcardFields();
gEditCard.card =
Components.classes["@mozilla.org/addressbook;1"]
.getService(Components.interfaces.nsIAddressBook)
Components.classes["@mozilla.org/abmanager;1"]
.getService(Components.interfaces.nsIAbManager)
.escapedVCardToAbCard(window.arguments[0].escapedVCardStr);
}

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

@ -368,8 +368,8 @@ function AbDeleteDirectory(aURI)
gPrefs.setCharPref("mail.collect_addressbook", kPersonalAddressbookURI);
}
Components.classes["@mozilla.org/addressbook;1"]
.getService(Components.interfaces.nsIAddressBook)
Components.classes["@mozilla.org/abmanager;1"]
.getService(Components.interfaces.nsIAbManager)
.deleteAddressBook(aURI);
}

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

@ -344,8 +344,8 @@ function AbPrintCardInternal(doPrintPreview, msgType)
if (!numSelected)
return;
var addressbook = Components.classes["@mozilla.org/addressbook;1"]
.getService(Components.interfaces.nsIAddressBook);
var addressbook = Components.classes["@mozilla.org/abmanager;1"]
.getService(Components.interfaces.nsIAbManager);
var uri = GetSelectedDirectory();
if (!uri)
return;
@ -400,8 +400,8 @@ function CreatePrintCardUrl(card)
function AbPrintAddressBookInternal(doPrintPreview, msgType)
{
var addressbook = Components.classes["@mozilla.org/addressbook;1"]
.getService(Components.interfaces.nsIAddressBook);
var addressbook = Components.classes["@mozilla.org/abManager;1"]
.getService(Components.interfaces.nsIAbManager);
var uri = GetSelectedDirectory();
if (!uri)
return;
@ -447,8 +447,8 @@ function AbExport()
if (!selectedABURI) return;
var directory = GetDirectoryFromURI(selectedABURI);
Components.classes["@mozilla.org/addressbook;1"]
.getService(Components.interfaces.nsIAddressBook)
Components.classes["@mozilla.org/abmanager;1"]
.getService(Components.interfaces.nsIAbManager)
.exportAddressBook(window, directory);
}
catch (ex) {

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

@ -56,6 +56,7 @@
#include "nsAbMDBDirFactory.h"
#include "nsAddrDatabase.h"
#include "nsAddressBook.h"
#include "nsAbContentHandler.h"
#include "nsAddrBookSession.h"
#include "nsAbDirProperty.h"
#include "nsAbAutoCompleteSession.h"
@ -98,7 +99,8 @@
#include "nsAbOSXDirFactory.h"
#endif
NS_GENERIC_FACTORY_CONSTRUCTOR(nsAddressBook)
NS_GENERIC_FACTORY_CONSTRUCTOR(nsAbManager)
NS_GENERIC_FACTORY_CONSTRUCTOR(nsAbContentHandler)
NS_GENERIC_FACTORY_CONSTRUCTOR_INIT(nsAbDirectoryDataSource,Init)
NS_GENERIC_FACTORY_CONSTRUCTOR(nsAbDirProperty)
NS_GENERIC_FACTORY_CONSTRUCTOR(nsAbCardProperty)
@ -153,17 +155,17 @@ NS_GENERIC_FACTORY_CONSTRUCTOR(nsAbLDIFService)
static const nsModuleComponentInfo components[] =
{
{ "Address Book",
NS_ADDRESSBOOK_CID,
NS_ADDRESSBOOK_CONTRACTID,
nsAddressBookConstructor },
{ "Address Book Manager",
NS_ABMANAGER_CID,
NS_ABMANAGER_CONTRACTID,
nsAbManagerConstructor },
{ "Address Book Startup Handler",
NS_ADDRESSBOOK_CID,
NS_ADDRESSBOOKSTARTUPHANDLER_CONTRACTID,
nsAddressBookConstructor,
nsAddressBook::RegisterProc,
nsAddressBook::UnregisterProc },
{ "Address Book Manager Startup Handler",
NS_ABMANAGER_CID,
NS_ABMANAGERSTARTUPHANDLER_CONTRACTID,
nsAbManagerConstructor,
nsAbManager::RegisterProc,
nsAbManager::UnregisterProc },
{ "Address Book Directory Datasource",
NS_ABDIRECTORYDATASOURCE_CID,
@ -222,14 +224,14 @@ static const nsModuleComponentInfo components[] =
nsAddbookProtocolHandlerConstructor },
{ "add vCard content handler",
NS_ADDRESSBOOK_CID,
NS_ABCONTENTHANDLER_CID,
NS_CONTENT_HANDLER_CONTRACTID_PREFIX"application/x-addvcard",
nsAddressBookConstructor },
nsAbContentHandlerConstructor },
{ "add vCard content handler",
NS_ADDRESSBOOK_CID,
NS_ABCONTENTHANDLER_CID,
NS_CONTENT_HANDLER_CONTRACTID_PREFIX"text/x-vcard",
nsAddressBookConstructor },
nsAbContentHandlerConstructor },
{ "The directory factory service interface",
NS_ABDIRFACTORYSERVICE_CID,

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

@ -278,8 +278,8 @@ function hasCharacters(number)
function onAccept()
{
var addressbook = Components.classes["@mozilla.org/addressbook;1"]
.getService(Components.interfaces.nsIAddressBook);
var addressbook = Components.classes["@mozilla.org/abmanager;1"]
.getService(Components.interfaces.nsIAbManager);
try {
var pref_string_content = "";

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

@ -358,8 +358,8 @@ function onAccept()
if (am) {
var addressbook;
try {
addressbook = Components.classes["@mozilla.org/addressbook;1"]
.getService(Components.interfaces.nsIAddressBook);
addressbook = Components.classes["@mozilla.org/abmanager;1"]
.getService(Components.interfaces.nsIAbManager);
}
catch(ex){
dump("Failed to get addressbook " + ex + "\n");

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

@ -49,18 +49,18 @@
"@mozilla.org/addressbook/directory-factory;1?name="
//
// nsAddressBook
// nsAbManager
//
#define NS_ADDRESSBOOK_CONTRACTID \
"@mozilla.org/addressbook;1"
#define NS_ABMANAGER_CONTRACTID \
"@mozilla.org/abmanager;1"
#define NS_ADDRESSBOOKSTARTUPHANDLER_CONTRACTID \
#define NS_ABMANAGERSTARTUPHANDLER_CONTRACTID \
"@mozilla.org/commandlinehandler/general-startup;1?type=addressbook"
#define NS_ADDRESSBOOK_CID \
{ /* {D60B84F2-2A8C-11d3-9E07-00A0C92B5F0D} */ \
0xd60b84f2, 0x2a8c, 0x11d3, \
{ 0x9e, 0x7, 0x0, 0xa0, 0xc9, 0x2b, 0x5f, 0xd } \
#define NS_ABMANAGER_CID \
{ /* {ad81b321-8a8a-42ca-a508-fe659de84586} */ \
0xad81b321, 0x8a8a, 0x42ca, \
{ 0xa5, 0x08, 0xfe, 0x65, 0x9d, 0x8e, 0x45, 0x86 } \
}
//

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

@ -1,81 +0,0 @@
/* -*- Mode: IDL; 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 "nsISupports.idl"
interface nsIDOMWindow;
interface nsIAbDirectory;
interface nsIAbCard;
interface nsIAbDirectoryProperties;
interface nsIRDFDataSource;
/**
* nsIAddressBook is an interface to the address book service accessible
* via the contract id "@mozilla.org/addressbook;1"
*
* It contains the main functions to create and delete address books as well
* as some helper functions.
*/
[scriptable, uuid(c741cb5d-0e65-4eab-8759-68189f541151)]
interface nsIAddressBook : nsISupports
{
/**
* Creates a new address book.
*
* @param aDirName The description of the address book.
*
* @param aURI The URI for the address book. This is specific to each
* type of address book.
*
* @param aType The type of the address book (see nsDirPrefs.h)
*/
ACString newAddressBook(in AString aDirName, in ACString aURI,
in unsigned long aType);
/**
* Deletes an address book.
*
* @param aURI The URI for the address book. This is specific to each
* type of address book.
*/
void deleteAddressBook(in ACString aURI);
void exportAddressBook(in nsIDOMWindow aParentWin, in nsIAbDirectory aDirectory);
boolean mailListNameExists(in wstring name);
nsIAbCard escapedVCardToAbCard(in string escapedVCardStr);
};

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

@ -92,8 +92,8 @@ function abNameOKButton()
if (gDirectory)
gDirectory.dirName = newName;
else
Components.classes["@mozilla.org/addressbook;1"]
.getService(Components.interfaces.nsIAddressBook)
Components.classes["@mozilla.org/abmanager;1"]
.getService(Components.interfaces.nsIAbManager)
.newAddressBook(newName, "", kPABDirectory);
return true;

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

@ -151,8 +151,8 @@ function OnLoadNewCard()
// hide non vcard values
HideNonVcardFields();
gEditCard.card =
Components.classes["@mozilla.org/addressbook;1"]
.getService(Components.interfaces.nsIAddressBook)
Components.classes["@mozilla.org/abmanager;1"]
.getService(Components.interfaces.nsIAbManager)
.escapedVCardToAbCard(window.arguments[0].escapedVCardStr);
}

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

@ -362,8 +362,8 @@ function AbDeleteDirectory(aURI)
gPrefs.setCharPref("mail.collect_addressbook", kPersonalAddressbookURI);
}
Components.classes["@mozilla.org/addressbook;1"]
.getService(Components.interfaces.nsIAddressBook)
Components.classes["@mozilla.org/abmanager;1"]
.getService(Components.interfaces.nsIAbManager)
.deleteAddressBook(aURI);
}

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

@ -66,8 +66,8 @@ function handleKeyPress(element, event)
function mailingListExists(listname)
{
var addressbook = Components.classes["@mozilla.org/addressbook;1"]
.getService(Components.interfaces.nsIAddressBook);
var addressbook = Components.classes["@mozilla.org/abmanager;1"]
.getService(Components.interfaces.nsIAbManager);
if (addressbook.mailListNameExists(listname))
{

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

@ -330,8 +330,8 @@ function AbPrintCardInternal(doPrintPreview, msgType)
if (!numSelected)
return;
var addressbook = Components.classes["@mozilla.org/addressbook;1"]
.getService(Components.interfaces.nsIAddressBook);
var addressbook = Components.classes["@mozilla.org/abmanager;1"]
.getService(Components.interfaces.nsIAbManager);
var uri = GetSelectedDirectory();
if (!uri)
@ -387,8 +387,8 @@ function CreatePrintCardUrl(card)
function AbPrintAddressBookInternal(doPrintPreview, msgType)
{
var addressbook = Components.classes["@mozilla.org/addressbook;1"]
.getService(Components.interfaces.nsIAddressBook);
var addressbook = Components.classes["@mozilla.org/abmanager;1"]
.getService(Components.interfaces.nsIAbManager);
var uri = GetSelectedDirectory();
if (!uri)
@ -435,8 +435,8 @@ function AbExport()
if (!selectedABURI) return;
var directory = GetDirectoryFromURI(selectedABURI);
Components.classes["@mozilla.org/addressbook;1"]
.getService(Components.interfaces.nsIAddressBook)
Components.classes["@mozilla.org/abmanager;1"]
.getService(Components.interfaces.nsIAbManager)
.exportAddressBook(window, directory);
}
catch (ex) {

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

@ -108,8 +108,8 @@ nsAbContentHandler::HandleContent(const char *aContentType,
if (!parentWindow)
return NS_ERROR_FAILURE;
nsCOMPtr<nsIAddressBook> ab =
do_GetService(NS_ADDRESSBOOK_CONTRACTID, &rv);
nsCOMPtr<nsIAbManager> ab =
do_GetService(NS_ABMANAGER_CONTRACTID, &rv);
NS_ENSURE_SUCCESS(rv, rv);
nsCOMPtr <nsIAbCard> cardFromVCard;
@ -182,8 +182,8 @@ nsAbContentHandler::OnStreamComplete(nsIStreamLoader *aLoader,
nsCString vCard;
vCard.Adopt(vCardService->WriteMemoryVObjects(0, &len, vObj, PR_FALSE));
nsCOMPtr<nsIAddressBook> ab =
do_GetService(NS_ADDRESSBOOK_CONTRACTID, &rv);
nsCOMPtr<nsIAbManager> ab =
do_GetService(NS_ABMANAGER_CONTRACTID, &rv);
NS_ENSURE_SUCCESS(rv, rv);
nsCOMPtr <nsIAbCard> cardFromVCard;

Разница между файлами не показана из-за своего большого размера Загрузить разницу

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

@ -1,70 +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 ***** */
#ifndef __nsAddressBook_h
#define __nsAddressBook_h
#include "nsIAddressBook.h"
#include "nsICommandLineHandler.h"
class nsILocalFile;
class nsIAbDirectory;
class nsIAbLDAPAttributeMap;
class nsAddressBook : public nsIAddressBook,
public nsICommandLineHandler
{
public:
nsAddressBook();
virtual ~nsAddressBook();
NS_DECL_ISUPPORTS
NS_DECL_NSIADDRESSBOOK
NS_DECL_NSICOMMANDLINEHANDLER
private:
nsresult ExportDirectoryToDelimitedText(nsIAbDirectory *aDirectory, const char *aDelim, PRUint32 aDelimLen, nsILocalFile *aLocalFile);
nsresult ExportDirectoryToLDIF(nsIAbDirectory *aDirectory, nsILocalFile *aLocalFile);
nsresult AppendLDIFForMailList(nsIAbCard *aCard, nsIAbLDAPAttributeMap *aAttrMap, nsACString &aResult);
nsresult AppendDNForCard(const char *aProperty, nsIAbCard *aCard, nsIAbLDAPAttributeMap *aAttrMap, nsACString &aResult);
nsresult AppendBasicLDIFForCard(nsIAbCard *aCard, nsIAbLDAPAttributeMap *aAttrMap, nsACString &aResult);
nsresult AppendProperty(const char *aProperty, const PRUnichar *aValue, nsACString &aResult);
PRBool IsSafeLDIFString(const PRUnichar *aStr);
};
#endif

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

@ -367,7 +367,7 @@ NS_GENERIC_FACTORY_CONSTRUCTOR(nsMsgCookiePolicy)
////////////////////////////////////////////////////////////////////////////////
// addrbook factories
////////////////////////////////////////////////////////////////////////////////
NS_GENERIC_FACTORY_CONSTRUCTOR(nsAddressBook)
NS_GENERIC_FACTORY_CONSTRUCTOR(nsAbManager)
NS_GENERIC_FACTORY_CONSTRUCTOR(nsAbContentHandler)
NS_GENERIC_FACTORY_CONSTRUCTOR_INIT(nsAbDirectoryDataSource,Init)
NS_GENERIC_FACTORY_CONSTRUCTOR(nsAbDirProperty)
@ -618,7 +618,7 @@ RegisterCommandLineHandlers(nsIComponentManager* compMgr, nsIFile* path,
NS_MESSENGERBOOTSTRAP_CONTRACTID,
PR_TRUE, PR_TRUE, nsnull);
rv |= catMan->AddCategoryEntry("command-line-handler", "m-addressbook",
NS_ADDRESSBOOK_CONTRACTID,
NS_ABMANAGER_CONTRACTID,
PR_TRUE, PR_TRUE, nsnull);
rv |= catMan->AddCategoryEntry("command-line-handler", "m-compose",
NS_MSGCOMPOSESERVICE_CONTRACTID,
@ -919,8 +919,8 @@ static const nsModuleComponentInfo gComponents[] = {
////////////////////////////////////////////////////////////////////////////////
// addrbook components
////////////////////////////////////////////////////////////////////////////////
{ "Address Book", NS_ADDRESSBOOK_CID,
NS_ADDRESSBOOK_CONTRACTID, nsAddressBookConstructor },
{ "Address Book Mananger", NS_ABMANAGER_CID,
NS_ABMANAGER_CONTRACTID, nsAbManagerConstructor },
{ "Address Book Directory Datasource", NS_ABDIRECTORYDATASOURCE_CID,
NS_ABDIRECTORYDATASOURCE_CONTRACTID, nsAbDirectoryDataSourceConstructor },
{ "Address Boot Strap Directory", NS_ABDIRECTORY_CID,
@ -1268,8 +1268,8 @@ static const nsModuleComponentInfo gComponents[] = {
////////////////////////////////////////////////////////////////////////////////
{ "Messenger Bootstrapper", NS_MESSENGERBOOTSTRAP_CID,
NS_MAILSTARTUPHANDLER_CONTRACTID, nsMessengerBootstrapConstructor },
{ "Address Book", NS_ADDRESSBOOK_CID,
NS_ADDRESSBOOKSTARTUPHANDLER_CONTRACTID, nsAddressBookConstructor },
{ "Address Book Manager Startup Handler", NS_ABMANAGER_CID,
NS_ABMANAGERSTARTUPHANDLER_CONTRACTID, nsAbManagerConstructor },
{ "Compose Service", NS_MSGCOMPOSESERVICE_CID,
NS_MSGCOMPOSESTARTUPHANDLER_CONTRACTID, nsMsgComposeServiceConstructor },
{ "NNTP Service", NS_NNTPSERVICE_CID,

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

@ -979,7 +979,7 @@ nsresult nsAbPalmHotSync::UpdateSyncInfo(long aCategoryIndex)
nsresult nsAbPalmHotSync::DeleteAB(const char* aABUrl)
{
nsresult rv;
nsCOMPtr<nsIAddressBook> ab(do_GetService(NS_ADDRESSBOOK_CONTRACTID, &rv));
nsCOMPtr<nsIAbManager> ab(do_GetService(NS_ABMANAGER_CONTRACTID, &rv));
NS_ENSURE_SUCCESS(rv, rv);
return ab->DeleteAddressBook(nsDependentCString(aABUrl));
@ -996,7 +996,7 @@ nsresult nsAbPalmHotSync::RenameAB(long aCategoryIndex, const char * aABUrl)
nsresult nsAbPalmHotSync::NewAB(const nsString& aAbName)
{
nsresult rv;
nsCOMPtr <nsIAddressBook> ab(do_GetService(NS_ADDRESSBOOK_CONTRACTID, &rv));
nsCOMPtr <nsIAbManager> ab(do_GetService(NS_ABMANAGER_CONTRACTID, &rv));
NS_ENSURE_SUCCESS(rv, rv);
// Don't actually need to keep the result