Back to index

lightning-sunbird  0.9+nobinonly
ipcModuleFactory.cpp
Go to the documentation of this file.
00001 /* ***** BEGIN LICENSE BLOCK *****
00002  * Version: MPL 1.1/GPL 2.0/LGPL 2.1
00003  *
00004  * The contents of this file are subject to the Mozilla Public License Version
00005  * 1.1 (the "License"); you may not use this file except in compliance with
00006  * the License. You may obtain a copy of the License at
00007  * http://www.mozilla.org/MPL/
00008  *
00009  * Software distributed under the License is distributed on an "AS IS" basis,
00010  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
00011  * for the specific language governing rights and limitations under the
00012  * License.
00013  *
00014  * The Original Code is Mozilla IPC.
00015  *
00016  * The Initial Developer of the Original Code is
00017  * Netscape Communications Corporation.
00018  * Portions created by the Initial Developer are Copyright (C) 2002
00019  * the Initial Developer. All Rights Reserved.
00020  *
00021  * Contributor(s):
00022  *   Darin Fisher <darin@netscape.com>
00023  *
00024  * Alternatively, the contents of this file may be used under the terms of
00025  * either the GNU General Public License Version 2 or later (the "GPL"), or
00026  * 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 "nsIServiceManager.h"
00039 #include "nsIGenericFactory.h"
00040 #include "nsICategoryManager.h"
00041 #include "ipcdclient.h"
00042 #include "ipcService.h"
00043 #include "ipcConfig.h"
00044 #include "ipcCID.h"
00045 
00046 //-----------------------------------------------------------------------------
00047 // Define the contructor function for the objects
00048 //
00049 // NOTE: This creates an instance of objects by using the default constructor
00050 //-----------------------------------------------------------------------------
00051 NS_GENERIC_FACTORY_CONSTRUCTOR(ipcService)
00052 
00053 // enable this code to make the IPC service auto-start.
00054 #if 0
00055 NS_METHOD
00056 ipcServiceRegisterProc(nsIComponentManager *aCompMgr,
00057                        nsIFile *aPath,
00058                        const char *registryLocation,
00059                        const char *componentType,
00060                        const nsModuleComponentInfo *info)
00061 {
00062     //
00063     // add ipcService to the XPCOM startup category
00064     //
00065     nsCOMPtr<nsICategoryManager> catman(do_GetService(NS_CATEGORYMANAGER_CONTRACTID));
00066     if (catman) {
00067         nsXPIDLCString prevEntry;
00068         catman->AddCategoryEntry(NS_XPCOM_STARTUP_OBSERVER_ID, "ipcService",
00069                                  IPC_SERVICE_CONTRACTID, PR_TRUE, PR_TRUE,
00070                                  getter_Copies(prevEntry));
00071     }
00072     return NS_OK;
00073 }
00074 
00075 NS_METHOD
00076 ipcServiceUnregisterProc(nsIComponentManager *aCompMgr,
00077                          nsIFile *aPath,
00078                          const char *registryLocation,
00079                          const nsModuleComponentInfo *info)
00080 {
00081     nsCOMPtr<nsICategoryManager> catman(do_GetService(NS_CATEGORYMANAGER_CONTRACTID));
00082     if (catman)
00083         catman->DeleteCategoryEntry(NS_XPCOM_STARTUP_OBSERVER_ID, 
00084                                     IPC_SERVICE_CONTRACTID, PR_TRUE);
00085     return NS_OK;
00086 }
00087 #endif
00088 
00089 //-----------------------------------------------------------------------------
00090 // extensions
00091 
00092 #include "ipcLockService.h"
00093 #include "ipcLockCID.h"
00094 NS_GENERIC_FACTORY_CONSTRUCTOR_INIT(ipcLockService, Init)
00095 
00096 #include "tmTransactionService.h"
00097 NS_GENERIC_FACTORY_CONSTRUCTOR(tmTransactionService)
00098 
00099 #ifdef BUILD_DCONNECT
00100 
00101 #include "ipcDConnectService.h"
00102 NS_GENERIC_FACTORY_CONSTRUCTOR_INIT(ipcDConnectService, Init)
00103 
00104 // enable this code to make the IPC DCONNECT service auto-start.
00105 NS_METHOD
00106 ipcDConnectServiceRegisterProc(nsIComponentManager *aCompMgr,
00107                                nsIFile *aPath,
00108                                const char *registryLocation,
00109                                const char *componentType,
00110                                const nsModuleComponentInfo *info)
00111 {
00112     //
00113     // add ipcService to the XPCOM startup category
00114     //
00115     nsCOMPtr<nsICategoryManager> catman(do_GetService(NS_CATEGORYMANAGER_CONTRACTID));
00116     if (catman) {
00117         nsXPIDLCString prevEntry;
00118         catman->AddCategoryEntry(NS_XPCOM_STARTUP_OBSERVER_ID, "ipcDConnectService",
00119                                  IPC_DCONNECTSERVICE_CONTRACTID, PR_TRUE, PR_TRUE,
00120                                  getter_Copies(prevEntry));
00121     }
00122     return NS_OK;
00123 }
00124 
00125 NS_METHOD
00126 ipcDConnectServiceUnregisterProc(nsIComponentManager *aCompMgr,
00127                                  nsIFile *aPath,
00128                                  const char *registryLocation,
00129                                  const nsModuleComponentInfo *info)
00130 {
00131     nsCOMPtr<nsICategoryManager> catman(do_GetService(NS_CATEGORYMANAGER_CONTRACTID));
00132     if (catman)
00133         catman->DeleteCategoryEntry(NS_XPCOM_STARTUP_OBSERVER_ID, 
00134                                     IPC_DCONNECTSERVICE_CONTRACTID, PR_TRUE);
00135     return NS_OK;
00136 }
00137 
00138 #endif // BUILD_DCONNECT
00139 
00140 //-----------------------------------------------------------------------------
00141 // Define a table of CIDs implemented by this module along with other
00142 // information like the function to create an instance, contractid, and
00143 // class name.
00144 //-----------------------------------------------------------------------------
00145 static const nsModuleComponentInfo components[] = {
00146   { IPC_SERVICE_CLASSNAME,
00147     IPC_SERVICE_CID,
00148     IPC_SERVICE_CONTRACTID,
00149     ipcServiceConstructor },
00150     /*
00151     ipcServiceRegisterProc,
00152     ipcServiceUnregisterProc },
00153     */
00154   //
00155   // extensions go here:
00156   //
00157   { IPC_LOCKSERVICE_CLASSNAME,
00158     IPC_LOCKSERVICE_CID,
00159     IPC_LOCKSERVICE_CONTRACTID,
00160     ipcLockServiceConstructor },
00161   { IPC_TRANSACTIONSERVICE_CLASSNAME,
00162     IPC_TRANSACTIONSERVICE_CID,
00163     IPC_TRANSACTIONSERVICE_CONTRACTID,
00164     tmTransactionServiceConstructor },
00165 
00166 #ifdef BUILD_DCONNECT
00167   { IPC_DCONNECTSERVICE_CLASSNAME,
00168     IPC_DCONNECTSERVICE_CID,
00169     IPC_DCONNECTSERVICE_CONTRACTID,
00170     ipcDConnectServiceConstructor,
00171     ipcDConnectServiceRegisterProc,
00172     ipcDConnectServiceUnregisterProc },
00173 #endif
00174 };
00175 
00176 //-----------------------------------------------------------------------------
00177 
00178 PR_STATIC_CALLBACK(nsresult)
00179 ipcdclient_init(nsIModule *module)
00180 {
00181   return IPC_Init();
00182 }
00183 
00184 PR_STATIC_CALLBACK(void)
00185 ipcdclient_shutdown(nsIModule *module)
00186 {
00187   IPC_Shutdown();
00188 }
00189 
00190 //-----------------------------------------------------------------------------
00191 // Implement the NSGetModule() exported function for your module
00192 // and the entire implementation of the module object.
00193 //-----------------------------------------------------------------------------
00194 NS_IMPL_NSGETMODULE_WITH_CTOR_DTOR(ipcdclient, components,
00195                                    ipcdclient_init,
00196                                    ipcdclient_shutdown)