Back to index

lightning-sunbird  0.9+nobinonly
nsAbFactory.cpp
Go to the documentation of this file.
00001 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
00002 /* ***** BEGIN LICENSE BLOCK *****
00003  * Version: MPL 1.1/GPL 2.0/LGPL 2.1
00004  *
00005  * The contents of this file are subject to the Mozilla Public License Version
00006  * 1.1 (the "License"); you may not use this file except in compliance with
00007  * the License. You may obtain a copy of the License at
00008  * http://www.mozilla.org/MPL/
00009  *
00010  * Software distributed under the License is distributed on an "AS IS" basis,
00011  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
00012  * for the specific language governing rights and limitations under the
00013  * License.
00014  *
00015  * The Original Code is mozilla.org code.
00016  *
00017  * The Initial Developer of the Original Code is
00018  * Netscape Communications Corporation.
00019  * Portions created by the Initial Developer are Copyright (C) 1998
00020  * the Initial Developer. All Rights Reserved.
00021  *
00022  * Contributor(s):
00023  *
00024  * Alternatively, the contents of this file may be used under the terms of
00025  * either of the GNU General Public License Version 2 or later (the "GPL"),
00026  * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
00027  * in which case the provisions of the GPL or the LGPL are applicable instead
00028  * of those above. If you wish to allow use of your version of this file only
00029  * under the terms of either the GPL or the LGPL, and not to allow others to
00030  * use your version of this file under the terms of the MPL, indicate your
00031  * decision by deleting the provisions above and replace them with the notice
00032  * and other provisions required by the GPL or the LGPL. If you do not delete
00033  * the provisions above, a recipient may use your version of this file under
00034  * the terms of any one of the MPL, the GPL or the LGPL.
00035  *
00036  * ***** END LICENSE BLOCK ***** */
00037 
00038 #include "nsIFactory.h"
00039 #include "nsISupports.h"
00040 #include "nsIGenericFactory.h"
00041 #include "nsIModule.h"
00042 
00043 #include "nsAbBaseCID.h"
00044 #include "pratom.h"
00045 #include "nsIComponentManager.h"
00046 #include "nsIServiceManager.h"
00047 #include "rdf.h"
00048 #include "nsCRT.h"
00049 #include "nsCOMPtr.h"
00050 
00051 #include "nsDirectoryDataSource.h"
00052 #include "nsAbBSDirectory.h"
00053 #include "nsAbMDBDirectory.h"
00054 #include "nsAbMDBCard.h"
00055 #include "nsAbDirFactoryService.h"
00056 #include "nsAbMDBDirFactory.h"
00057 #include "nsAddrDatabase.h"
00058 #include "nsAddressBook.h"
00059 #include "nsAddrBookSession.h"
00060 #include "nsAbDirProperty.h"
00061 #include "nsAbAutoCompleteSession.h"
00062 #include "nsAbAddressCollecter.h"
00063 #include "nsAddbookProtocolHandler.h"
00064 #include "nsAddbookUrl.h"
00065 #include "nsCURILoader.h"
00066 
00067 #if defined(XP_WIN) && !defined(__MINGW32__)
00068 #include "nsAbOutlookDirectory.h"
00069 #include "nsAbOutlookCard.h"
00070 #include "nsAbOutlookDirFactory.h"
00071 #endif
00072 
00073 #include "nsAbDirectoryQuery.h"
00074 #include "nsAbBooleanExpression.h"
00075 #include "nsAbDirectoryQueryProxy.h"
00076 #include "nsAbView.h"
00077 #include "nsMsgVCardService.h"
00078 #include "nsAbLDIFService.h"
00079 
00080 #if defined(MOZ_LDAP_XPCOM)
00081 #include "nsAbLDAPDirectory.h"
00082 #include "nsAbLDAPCard.h"
00083 #include "nsAbLDAPDirFactory.h"
00084 #include "nsAbLDAPAutoCompFormatter.h"
00085 #include "nsAbLDAPReplicationService.h"
00086 #include "nsAbLDAPReplicationQuery.h"
00087 #include "nsAbLDAPReplicationData.h"
00088 #include "nsAbLDAPChangeLogQuery.h"
00089 #include "nsAbLDAPChangeLogData.h"
00090 #endif
00091 
00092 #ifdef XP_MACOSX
00093 #include "nsAbOSXDirectory.h"
00094 #include "nsAbOSXCard.h"
00095 #include "nsAbOSXDirFactory.h"
00096 #endif
00097 
00098 NS_GENERIC_FACTORY_CONSTRUCTOR(nsAddressBook)
00099 NS_GENERIC_FACTORY_CONSTRUCTOR_INIT(nsAbDirectoryDataSource,Init)
00100 NS_GENERIC_FACTORY_CONSTRUCTOR(nsAbDirProperty)
00101 NS_GENERIC_FACTORY_CONSTRUCTOR(nsAbDirectoryProperties)
00102 NS_GENERIC_FACTORY_CONSTRUCTOR(nsAbCardProperty)
00103 NS_GENERIC_FACTORY_CONSTRUCTOR(nsAbBSDirectory)
00104 NS_GENERIC_FACTORY_CONSTRUCTOR(nsAbMDBDirectory)
00105 NS_GENERIC_FACTORY_CONSTRUCTOR(nsAbMDBCard)
00106 NS_GENERIC_FACTORY_CONSTRUCTOR(nsAddrDatabase)
00107 NS_GENERIC_FACTORY_CONSTRUCTOR(nsAddrBookSession)
00108 NS_GENERIC_FACTORY_CONSTRUCTOR(nsAbAutoCompleteSession)
00109 NS_GENERIC_FACTORY_CONSTRUCTOR_INIT(nsAbAddressCollecter,Init)
00110 NS_GENERIC_FACTORY_CONSTRUCTOR(nsAddbookUrl)
00111 NS_GENERIC_FACTORY_CONSTRUCTOR(nsAbDirFactoryService)
00112 NS_GENERIC_FACTORY_CONSTRUCTOR(nsAbMDBDirFactory)
00113 NS_GENERIC_FACTORY_CONSTRUCTOR(nsAddbookProtocolHandler)
00114 
00115 #if defined(XP_WIN) && !defined(__MINGW32__)
00116 NS_GENERIC_FACTORY_CONSTRUCTOR(nsAbOutlookDirectory)
00117 NS_GENERIC_FACTORY_CONSTRUCTOR(nsAbOutlookCard)
00118 NS_GENERIC_FACTORY_CONSTRUCTOR(nsAbOutlookDirFactory)
00119 #endif
00120 
00121 NS_GENERIC_FACTORY_CONSTRUCTOR(nsAbDirectoryQueryArguments)
00122 NS_GENERIC_FACTORY_CONSTRUCTOR(nsAbBooleanConditionString)
00123 NS_GENERIC_FACTORY_CONSTRUCTOR(nsAbBooleanExpression)
00124 
00125 #if defined(MOZ_LDAP_XPCOM)
00126 NS_GENERIC_FACTORY_CONSTRUCTOR(nsAbLDAPDirectory)
00127 NS_GENERIC_FACTORY_CONSTRUCTOR(nsAbLDAPCard)
00128 NS_GENERIC_FACTORY_CONSTRUCTOR(nsAbLDAPDirFactory)
00129 NS_GENERIC_FACTORY_CONSTRUCTOR(nsAbLDAPAutoCompFormatter)
00130 NS_GENERIC_FACTORY_CONSTRUCTOR(nsAbLDAPReplicationService)
00131 NS_GENERIC_FACTORY_CONSTRUCTOR(nsAbLDAPReplicationQuery)
00132 NS_GENERIC_FACTORY_CONSTRUCTOR(nsAbLDAPProcessReplicationData)
00133 NS_GENERIC_FACTORY_CONSTRUCTOR(nsAbLDAPChangeLogQuery)
00134 NS_GENERIC_FACTORY_CONSTRUCTOR(nsAbLDAPProcessChangeLogData)
00135 #endif
00136 
00137 NS_GENERIC_FACTORY_CONSTRUCTOR(nsAbDirectoryQueryProxy)
00138 #if 0
00139 #ifdef XP_MACOSX
00140 NS_GENERIC_FACTORY_CONSTRUCTOR(nsAbOSXDirectory)
00141 NS_GENERIC_FACTORY_CONSTRUCTOR(nsAbOSXCard)
00142 NS_GENERIC_FACTORY_CONSTRUCTOR(nsAbOSXDirFactory)
00143 #endif
00144 #endif
00145 NS_GENERIC_FACTORY_CONSTRUCTOR(nsAbView)
00146 NS_GENERIC_FACTORY_CONSTRUCTOR(nsMsgVCardService)
00147 NS_GENERIC_FACTORY_CONSTRUCTOR(nsAbLDIFService)
00148 
00149 static const nsModuleComponentInfo components[] =
00150 {
00151   { "Address Book",
00152     NS_ADDRESSBOOK_CID,
00153     NS_ADDRESSBOOK_CONTRACTID,
00154     nsAddressBookConstructor },
00155 
00156   { "Address Book Startup Handler",
00157     NS_ADDRESSBOOK_CID,
00158     NS_ADDRESSBOOKSTARTUPHANDLER_CONTRACTID,
00159     nsAddressBookConstructor,
00160     nsAddressBook::RegisterProc,
00161     nsAddressBook::UnregisterProc },
00162 
00163   { "Address Book Directory Datasource",
00164     NS_ABDIRECTORYDATASOURCE_CID,
00165     NS_ABDIRECTORYDATASOURCE_CONTRACTID,
00166     nsAbDirectoryDataSourceConstructor },
00167 
00168   { "Address Boot Strap Directory",
00169     NS_ABDIRECTORY_CID,
00170     NS_ABDIRECTORY_CONTRACTID,
00171     nsAbBSDirectoryConstructor },
00172 
00173   { "Address MDB Book Directory",
00174     NS_ABMDBDIRECTORY_CID,
00175     NS_ABMDBDIRECTORY_CONTRACTID,
00176     nsAbMDBDirectoryConstructor },
00177 
00178   { "Address MDB Book Card",
00179     NS_ABMDBCARD_CID,
00180     NS_ABMDBCARD_CONTRACTID,
00181     nsAbMDBCardConstructor },
00182 
00183   { "Address Database",
00184     NS_ADDRDATABASE_CID,
00185     NS_ADDRDATABASE_CONTRACTID,
00186     nsAddrDatabaseConstructor },
00187 
00188   { "Address Book Card Property",
00189     NS_ABCARDPROPERTY_CID,
00190     NS_ABCARDPROPERTY_CONTRACTID,
00191     nsAbCardPropertyConstructor },
00192 
00193   { "Address Book Directory Property",
00194     NS_ABDIRPROPERTY_CID,
00195     NS_ABDIRPROPERTY_CONTRACTID,
00196     nsAbDirPropertyConstructor },
00197   { "AB Directory Properties",
00198     NS_ABDIRECTORYPROPERTIES_CID,
00199     NS_ABDIRECTORYPROPERTIES_CONTRACTID,
00200     nsAbDirectoryPropertiesConstructor },
00201   { "Address Book Session",
00202     NS_ADDRBOOKSESSION_CID,
00203     NS_ADDRBOOKSESSION_CONTRACTID,
00204     nsAddrBookSessionConstructor },
00205   { "Address Book Auto Complete Session",
00206     NS_ABAUTOCOMPLETESESSION_CID,
00207     NS_ABAUTOCOMPLETESESSION_CONTRACTID,
00208     nsAbAutoCompleteSessionConstructor },
00209   { "Address Book Address Collector",
00210     NS_ABADDRESSCOLLECTER_CID,
00211     NS_ABADDRESSCOLLECTER_CONTRACTID,
00212     nsAbAddressCollecterConstructor },
00213   { "The addbook URL Interface", 
00214     NS_ADDBOOKURL_CID,
00215     NS_ADDBOOKURL_CONTRACTID,
00216     nsAddbookUrlConstructor },
00217     
00218   { "The addbook Protocol Handler", 
00219     NS_ADDBOOK_HANDLER_CID,
00220     NS_NETWORK_PROTOCOL_CONTRACTID_PREFIX "addbook",
00221     nsAddbookProtocolHandlerConstructor },
00222 
00223   { "add vCard content handler",
00224     NS_ADDRESSBOOK_CID,
00225     NS_CONTENT_HANDLER_CONTRACTID_PREFIX"application/x-addvcard",
00226     nsAddressBookConstructor },
00227 
00228   { "add vCard content handler",
00229     NS_ADDRESSBOOK_CID,
00230     NS_CONTENT_HANDLER_CONTRACTID_PREFIX"text/x-vcard",
00231     nsAddressBookConstructor },
00232 
00233   { "The directory factory service interface",
00234     NS_ABDIRFACTORYSERVICE_CID,
00235     NS_ABDIRFACTORYSERVICE_CONTRACTID,
00236     nsAbDirFactoryServiceConstructor },
00237 
00238   { "The MDB directory factory interface",
00239     NS_ABMDBDIRFACTORY_CID,
00240     NS_ABMDBDIRFACTORY_CONTRACTID,
00241     nsAbMDBDirFactoryConstructor },
00242 
00243 #if defined(XP_WIN) && !defined(__MINGW32__)
00244   { "Address OUTLOOK Book Directory",
00245     NS_ABOUTLOOKDIRECTORY_CID,
00246     NS_ABOUTLOOKDIRECTORY_CONTRACTID,
00247     nsAbOutlookDirectoryConstructor },
00248 
00249   { "Address OUTLOOK Book Card",
00250     NS_ABOUTLOOKCARD_CID,
00251     NS_ABOUTLOOKCARD_CONTRACTID,
00252     nsAbOutlookCardConstructor },
00253 
00254   { "The outlook factory Interface", 
00255     NS_ABOUTLOOKDIRFACTORY_CID,
00256     NS_ABOUTLOOKDIRFACTORY_CONTRACTID,
00257     nsAbOutlookDirFactoryConstructor },
00258 #endif
00259 
00260   { "The addbook query arguments", 
00261     NS_ABDIRECTORYQUERYARGUMENTS_CID,
00262     NS_ABDIRECTORYQUERYARGUMENTS_CONTRACTID,
00263     nsAbDirectoryQueryArgumentsConstructor },
00264     
00265   { "The query boolean condition string", 
00266     NS_BOOLEANCONDITIONSTRING_CID,
00267     NS_BOOLEANCONDITIONSTRING_CONTRACTID,
00268     nsAbBooleanConditionStringConstructor },
00269     
00270   { "The query n-peer expression", 
00271     NS_BOOLEANEXPRESSION_CID,
00272     NS_BOOLEANEXPRESSION_CONTRACTID,
00273     nsAbBooleanExpressionConstructor },
00274 
00275 #if defined(MOZ_LDAP_XPCOM)
00276   { "Address LDAP Book Directory",
00277     NS_ABLDAPDIRECTORY_CID,
00278     NS_ABLDAPDIRECTORY_CONTRACTID,
00279     nsAbLDAPDirectoryConstructor },
00280 
00281   { "Address LDAP Book Card",
00282     NS_ABLDAPCARD_CID,
00283     NS_ABLDAPCARD_CONTRACTID,
00284     nsAbLDAPCardConstructor },
00285 
00286   { "Address LDAP factory Interface", 
00287     NS_ABLDAPDIRFACTORY_CID,
00288     NS_ABLDAPDIRFACTORY_CONTRACTID,
00289     nsAbLDAPDirFactoryConstructor },
00290 
00291  {"Address LDAP Replication Service Interface",
00292    NS_ABLDAP_REPLICATIONSERVICE_CID,
00293    NS_ABLDAP_REPLICATIONSERVICE_CONTRACTID,
00294    nsAbLDAPReplicationServiceConstructor },
00295 
00296  {"Address LDAP Replication Query Interface",
00297    NS_ABLDAP_REPLICATIONQUERY_CID,
00298    NS_ABLDAP_REPLICATIONQUERY_CONTRACTID,
00299    nsAbLDAPReplicationQueryConstructor },
00300 
00301  {"Address LDAP Replication Processor Interface",
00302    NS_ABLDAP_PROCESSREPLICATIONDATA_CID,
00303    NS_ABLDAP_PROCESSREPLICATIONDATA_CONTRACTID,
00304    nsAbLDAPProcessReplicationDataConstructor },
00305 
00306  {"Address LDAP ChangeLog Query Interface",
00307    NS_ABLDAP_CHANGELOGQUERY_CID,
00308    NS_ABLDAP_CHANGELOGQUERY_CONTRACTID,
00309    nsAbLDAPChangeLogQueryConstructor },
00310 
00311  {"Address LDAP ChangeLog Processor Interface",
00312    NS_ABLDAP_PROCESSCHANGELOGDATA_CID,
00313    NS_ABLDAP_PROCESSCHANGELOGDATA_CONTRACTID,
00314    nsAbLDAPProcessChangeLogDataConstructor },
00315 
00316   { "Address LDAP autocomplete factory Interface", 
00317     NS_ABLDAPDIRFACTORY_CID,
00318     NS_ABLDAPACDIRFACTORY_CONTRACTID,
00319     nsAbLDAPDirFactoryConstructor },
00320 
00321   { "Address LDAP over SSL autocomplete factory Interface", 
00322     NS_ABLDAPDIRFACTORY_CID,
00323     NS_ABLDAPSACDIRFACTORY_CONTRACTID,
00324     nsAbLDAPDirFactoryConstructor },
00325 
00326   { "Address book LDAP autocomplete formatter",
00327     NS_ABLDAPAUTOCOMPFORMATTER_CID,
00328     NS_ABLDAPAUTOCOMPFORMATTER_CONTRACTID,
00329     nsAbLDAPAutoCompFormatterConstructor },
00330 
00331 #endif
00332 
00333   { "The directory query proxy interface",
00334     NS_ABDIRECTORYQUERYPROXY_CID,
00335     NS_ABDIRECTORYQUERYPROXY_CONTRACTID,
00336     nsAbDirectoryQueryProxyConstructor },
00337 #if 0
00338 #ifdef XP_MACOSX
00339   { "OS X Address Book Directory",
00340     NS_ABOSXDIRECTORY_CID,
00341     NS_ABOSXDIRECTORY_CONTRACTID,
00342     nsAbOSXDirectoryConstructor },
00343 
00344   { "OS X Address Book Card",
00345     NS_ABOSXCARD_CID,
00346     NS_ABOSXCARD_CONTRACTID,
00347     nsAbOSXCardConstructor },
00348 
00349   { "The OS X factory Interface", 
00350     NS_ABOSXDIRFACTORY_CID,
00351     NS_ABOSXDIRFACTORY_CONTRACTID,
00352     nsAbOSXDirFactoryConstructor },
00353 #endif
00354 #endif
00355   { "addressbook view",
00356     NS_ABVIEW_CID,
00357     NS_ABVIEW_CONTRACTID,
00358     nsAbViewConstructor },
00359 
00360   { "vcard helper service",
00361     NS_MSGVCARDSERVICE_CID,
00362     NS_MSGVCARDSERVICE_CONTRACTID,
00363     nsMsgVCardServiceConstructor },
00364 
00365   { "ldif handler service",
00366     NS_ABLDIFSERVICE_CID,
00367     NS_ABLDIFSERVICE_CONTRACTID,
00368     nsAbLDIFServiceConstructor }
00369 };
00370 
00371 
00372 PR_STATIC_CALLBACK(void)
00373 msgAbModuleDtor(nsIModule* self)
00374 {
00375     nsAddrDatabase::CleanupCache();
00376 }
00377 
00378 NS_IMPL_NSGETMODULE_WITH_DTOR(nsAbModule, components, msgAbModuleDtor)
00379