Bug 462438 - kill MOZ_PROFILESHARING and MOZ_IPCD; build system cleanup + removes, v2; r+sr=benjamin a191=beltzner
authorArpad Borsos <arpad.borsos@googlemail.com>
Mon, 08 Dec 2008 02:16:53 +0100
changeset 22196 264c645590926e62f2662d8c140af8a151619ef6
parent 22195 56aa85cdead5f4452f68acfb3bc1c38943cfa25b
child 22197 c6c957beb1264806dbad2ce4611b35b800af4d2a
push id92
push usersgautherie.bz@free.fr
push dateMon, 08 Dec 2008 01:17:55 +0000
bugs462438
milestone1.9.1b3pre
Bug 462438 - kill MOZ_PROFILESHARING and MOZ_IPCD; build system cleanup + removes, v2; r+sr=benjamin a191=beltzner
config/autoconf.mk.in
configure.in
embedding/components/Makefile.in
embedding/components/build/Makefile.in
embedding/components/profilesharingsetup/Makefile.in
embedding/components/profilesharingsetup/public/Makefile.in
embedding/components/profilesharingsetup/public/nsIProfileSharingSetup.idl
embedding/components/profilesharingsetup/src/Makefile.in
embedding/components/profilesharingsetup/src/nsProfileSharingSetup.cpp
embedding/components/profilesharingsetup/src/nsProfileSharingSetup.h
ipc/ipcd/Makefile.in
ipc/ipcd/client/public/Makefile.in
ipc/ipcd/client/public/ipcCID.h
ipc/ipcd/client/public/ipcIClientObserver.idl
ipc/ipcd/client/public/ipcIMessageObserver.idl
ipc/ipcd/client/public/ipcIService.idl
ipc/ipcd/client/public/ipcdclient.h
ipc/ipcd/client/src/Makefile.in
ipc/ipcd/client/src/ipcConnection.h
ipc/ipcd/client/src/ipcConnectionStub.cpp
ipc/ipcd/client/src/ipcConnectionUnix.cpp
ipc/ipcd/client/src/ipcConnectionWin.cpp
ipc/ipcd/client/src/ipcModuleFactory.cpp
ipc/ipcd/client/src/ipcService.cpp
ipc/ipcd/client/src/ipcService.h
ipc/ipcd/client/src/ipcdclient.cpp
ipc/ipcd/daemon/public/Makefile.in
ipc/ipcd/daemon/public/ipcModule.h
ipc/ipcd/daemon/public/ipcModuleUtil.h
ipc/ipcd/daemon/src/Makefile.in
ipc/ipcd/daemon/src/ipcClient.cpp
ipc/ipcd/daemon/src/ipcClient.h
ipc/ipcd/daemon/src/ipcCommandModule.cpp
ipc/ipcd/daemon/src/ipcCommandModule.h
ipc/ipcd/daemon/src/ipcModuleReg.cpp
ipc/ipcd/daemon/src/ipcModuleReg.h
ipc/ipcd/daemon/src/ipcd.cpp
ipc/ipcd/daemon/src/ipcd.h
ipc/ipcd/daemon/src/ipcdPrivate.h
ipc/ipcd/daemon/src/ipcdStub.cpp
ipc/ipcd/daemon/src/ipcdUnix.cpp
ipc/ipcd/daemon/src/ipcdWin.cpp
ipc/ipcd/extensions/Makefile.in
ipc/ipcd/extensions/dconnect/Makefile.in
ipc/ipcd/extensions/dconnect/public/Makefile.in
ipc/ipcd/extensions/dconnect/public/ipcIDConnectService.idl
ipc/ipcd/extensions/dconnect/src/Makefile.in
ipc/ipcd/extensions/dconnect/src/ipcDConnectService.cpp
ipc/ipcd/extensions/dconnect/src/ipcDConnectService.h
ipc/ipcd/extensions/dconnect/test/Makefile.in
ipc/ipcd/extensions/dconnect/test/TestClient.js
ipc/ipcd/extensions/dconnect/test/TestDConnect.cpp
ipc/ipcd/extensions/dconnect/test/TestServer.js
ipc/ipcd/extensions/lock/Makefile.in
ipc/ipcd/extensions/lock/public/Makefile.in
ipc/ipcd/extensions/lock/public/ipcILockService.idl
ipc/ipcd/extensions/lock/public/ipcLockCID.h
ipc/ipcd/extensions/lock/src/Makefile.in
ipc/ipcd/extensions/lock/src/ipcLockProtocol.cpp
ipc/ipcd/extensions/lock/src/ipcLockProtocol.h
ipc/ipcd/extensions/lock/src/ipcLockService.cpp
ipc/ipcd/extensions/lock/src/ipcLockService.h
ipc/ipcd/extensions/lock/src/module/Makefile.in
ipc/ipcd/extensions/lock/src/module/ipcLockModule.cpp
ipc/ipcd/extensions/lock/test/Makefile.in
ipc/ipcd/extensions/lock/test/TestIPCLocks.cpp
ipc/ipcd/extensions/transmngr/Makefile.in
ipc/ipcd/extensions/transmngr/build/Makefile.in
ipc/ipcd/extensions/transmngr/build/tmCID.h
ipc/ipcd/extensions/transmngr/build/tmModule.cpp
ipc/ipcd/extensions/transmngr/common/Makefile.in
ipc/ipcd/extensions/transmngr/common/tmTransaction.cpp
ipc/ipcd/extensions/transmngr/common/tmTransaction.h
ipc/ipcd/extensions/transmngr/common/tmUtils.h
ipc/ipcd/extensions/transmngr/common/tmVector.cpp
ipc/ipcd/extensions/transmngr/common/tmVector.h
ipc/ipcd/extensions/transmngr/module/Makefile.in
ipc/ipcd/extensions/transmngr/module/tmIPCModule.cpp
ipc/ipcd/extensions/transmngr/module/tmIPCModule.h
ipc/ipcd/extensions/transmngr/module/tmQueue.cpp
ipc/ipcd/extensions/transmngr/module/tmQueue.h
ipc/ipcd/extensions/transmngr/module/tmTransactionManager.cpp
ipc/ipcd/extensions/transmngr/module/tmTransactionManager.h
ipc/ipcd/extensions/transmngr/public/Makefile.in
ipc/ipcd/extensions/transmngr/public/ipcITransactionObserver.idl
ipc/ipcd/extensions/transmngr/public/ipcITransactionService.idl
ipc/ipcd/extensions/transmngr/src/Makefile.in
ipc/ipcd/extensions/transmngr/src/tmTransactionService.cpp
ipc/ipcd/extensions/transmngr/src/tmTransactionService.h
ipc/ipcd/extensions/transmngr/test/Makefile.in
ipc/ipcd/extensions/transmngr/test/tmModuleTest.cpp
ipc/ipcd/shared/src/Makefile.in
ipc/ipcd/shared/src/ipcConfig.cpp
ipc/ipcd/shared/src/ipcConfig.h
ipc/ipcd/shared/src/ipcIDList.cpp
ipc/ipcd/shared/src/ipcIDList.h
ipc/ipcd/shared/src/ipcList.h
ipc/ipcd/shared/src/ipcLog.cpp
ipc/ipcd/shared/src/ipcLog.h
ipc/ipcd/shared/src/ipcMessage.cpp
ipc/ipcd/shared/src/ipcMessage.h
ipc/ipcd/shared/src/ipcMessagePrimitives.cpp
ipc/ipcd/shared/src/ipcMessagePrimitives.h
ipc/ipcd/shared/src/ipcMessageQ.h
ipc/ipcd/shared/src/ipcMessageUtils.h
ipc/ipcd/shared/src/ipcStringList.cpp
ipc/ipcd/shared/src/ipcStringList.h
ipc/ipcd/shared/src/ipcm.cpp
ipc/ipcd/shared/src/ipcm.h
ipc/ipcd/test/Makefile.in
ipc/ipcd/test/TestIPC.cpp
ipc/ipcd/test/module/Makefile.in
ipc/ipcd/test/module/TestModule.cpp
ipc/ipcd/util/Makefile.in
ipc/ipcd/util/public/Makefile.in
ipc/ipcd/util/public/ipcMessageReader.h
ipc/ipcd/util/public/ipcMessageWriter.h
ipc/ipcd/util/src/Makefile.in
ipc/ipcd/util/src/ipcMessageReader.cpp
ipc/ipcd/util/src/ipcMessageWriter.cpp
modules/libpref/src/Makefile.in
modules/libpref/src/init/non-shared.txt
modules/libpref/src/nsSharedPrefHandler.cpp
modules/libpref/src/nsSharedPrefHandler.h
netwerk/confvars.sh
profile/dirserviceprovider/src/Makefile.in
profile/dirserviceprovider/standalone/Makefile.in
toolkit/library/libxul-config.mk
toolkit/toolkit-makefiles.sh
toolkit/toolkit-tiers.mk
--- a/config/autoconf.mk.in
+++ b/config/autoconf.mk.in
@@ -139,18 +139,16 @@ MOZ_UPDATER	= @MOZ_UPDATER@
 MOZ_UPDATE_PACKAGING	= @MOZ_UPDATE_PACKAGING@
 MOZ_NO_ACTIVEX_SUPPORT = @MOZ_NO_ACTIVEX_SUPPORT@
 MOZ_ACTIVEX_SCRIPTING_SUPPORT = @MOZ_ACTIVEX_SCRIPTING_SUPPORT@
 MOZ_DISABLE_VISTA_SDK_REQUIREMENTS = @MOZ_DISABLE_VISTA_SDK_REQUIREMENTS@
 MOZ_DISABLE_PARENTAL_CONTROLS = @MOZ_DISABLE_PARENTAL_CONTROLS@
 XPC_IDISPATCH_SUPPORT = @XPC_IDISPATCH_SUPPORT@
 MOZ_SPELLCHECK = @MOZ_SPELLCHECK@
 MOZ_XPFE_COMPONENTS = @MOZ_XPFE_COMPONENTS@
-MOZ_IPCD = @MOZ_IPCD@
-MOZ_PROFILESHARING = @MOZ_PROFILESHARING@
 MOZ_PROFILELOCKING = @MOZ_PROFILELOCKING@
 MOZ_FEEDS = @MOZ_FEEDS@
 MOZ_PLACES = @MOZ_PLACES@
 MOZ_PLACES_BOOKMARKS = @MOZ_PLACES_BOOKMARKS@
 MOZ_STORAGE = @MOZ_STORAGE@
 MOZ_SAFE_BROWSING = @MOZ_SAFE_BROWSING@
 MOZ_URL_CLASSIFIER = @MOZ_URL_CLASSIFIER@
 MOZ_ZIPWRITER = @MOZ_ZIPWRITER@
--- a/configure.in
+++ b/configure.in
@@ -4294,17 +4294,16 @@ BUILD_STATIC_LIBS=
 ENABLE_TESTS=1
 MOZ_ACTIVEX_SCRIPTING_SUPPORT=
 MOZ_BRANDING_DIRECTORY=
 MOZ_DBGRINFO_MODULES=
 MOZ_ENABLE_CANVAS=1
 MOZ_FEEDS=1
 MOZ_IMG_DECODERS_DEFAULT="png gif jpeg bmp xbm icon"
 MOZ_IMG_ENCODERS_DEFAULT="png jpeg"
-MOZ_IPCD=
 MOZ_JAVAXPCOM=
 MOZ_JSDEBUGGER=1
 MOZ_JSLOADER=1
 MOZ_LIBART_CFLAGS=
 MOZ_LIBART_LIBS=
 MOZ_MATHML=1
 MOZ_MORK=1
 MOZ_MORKREADER=
@@ -4319,17 +4318,16 @@ MOZ_WAVE=1
 MOZ_MEDIA=
 MOZ_OJI=1
 MOZ_PERMISSIONS=1
 MOZ_PLACES=
 MOZ_PLAINTEXT_EDITOR_ONLY=
 MOZ_PLUGINS=1
 MOZ_PREF_EXTENSIONS=1
 MOZ_PROFILELOCKING=1
-MOZ_PROFILESHARING=1
 MOZ_PSM=1
 MOZ_PYTHON_EXTENSIONS="xpcom dom"
 MOZ_PYTHON=
 MOZ_PYTHON_DEBUG_SUFFIX=
 MOZ_PYTHON_DLL_SUFFIX=
 MOZ_PYTHON_INCLUDES=
 MOZ_PYTHON_LIBS=
 MOZ_PYTHON_PREFIX=
@@ -4434,17 +4432,16 @@ basic)
   MOZ_NO_INSPECTOR_APIS=1
   MOZ_NO_XPCOM_OBSOLETE=1
   MOZ_NO_FAST_LOAD=1
   MOZ_OJI=
   MOZ_PLAINTEXT_EDITOR_ONLY=1
 #  MOZ_PLUGINS=
   MOZ_PREF_EXTENSIONS=
   MOZ_PROFILELOCKING=
-  MOZ_PROFILESHARING=
   MOZ_SPELLCHECK=
   MOZ_SVG=
   MOZ_UNIVERSALCHARDET=
   MOZ_UPDATER=
   MOZ_USE_NATIVE_UCONV=
   MOZ_VIEW_SOURCE=
   MOZ_XPFE_COMPONENTS=
   MOZ_XPINSTALL=
@@ -4479,17 +4476,16 @@ minimal)
   MOZ_NO_INSPECTOR_APIS=1
   MOZ_NO_XPCOM_OBSOLETE=1
   MOZ_NO_FAST_LOAD=1
   MOZ_OJI=
   MOZ_PLAINTEXT_EDITOR_ONLY=1
   MOZ_PLUGINS=
   MOZ_PREF_EXTENSIONS=
   MOZ_PROFILELOCKING=
-  MOZ_PROFILESHARING=
   MOZ_SPELLCHECK=
   MOZ_STORAGE=1
   MOZ_PLACES=
   MOZ_SVG=
   MOZ_UNIVERSALCHARDET=
   MOZ_UPDATER=
   MOZ_USE_NATIVE_UCONV=1
   MOZ_VIEW_SOURCE=
@@ -4598,17 +4594,16 @@ fi
 AC_SUBST(MOZ_BUILD_APP)
 AC_SUBST(MOZ_XUL_APP)
 AC_SUBST(MOZ_PHOENIX)
 AC_SUBST(MOZ_XULRUNNER)
 
 AC_DEFINE_UNQUOTED(MOZ_BUILD_APP,$MOZ_BUILD_APP)
 
 if test "$MOZ_XUL_APP"; then
-  MOZ_PROFILESHARING=
   AC_DEFINE(MOZ_XUL_APP)
 fi
 
 dnl ========================================================
 dnl = 
 dnl = Toolkit Options
 dnl = 
 dnl ========================================================
@@ -7618,36 +7613,16 @@ AC_SUBST(MOZ_PYTHON_PREFIX)
 AC_SUBST(MOZ_PYTHON_INCLUDES)
 AC_SUBST(MOZ_PYTHON_LIBS)
 AC_SUBST(MOZ_PYTHON_VER)
 AC_SUBST(MOZ_PYTHON_VER_DOTTED)
 AC_SUBST(MOZ_PYTHON_DEBUG_SUFFIX)
 AC_SUBST(MOZ_PYTHON_DLL_SUFFIX)
 
 dnl ========================================================
-dnl disable profile sharing
-dnl ========================================================
-MOZ_ARG_DISABLE_BOOL(profilesharing,
-[  --disable-profilesharing           Disable profile sharing],
-    MOZ_PROFILESHARING=,
-    MOZ_PROFILESHARING=1 )
-if test "$MOZ_PROFILESHARING"; then
-  MOZ_IPCD=1
-  AC_DEFINE(MOZ_PROFILESHARING)
-fi
-
-dnl ========================================================
-dnl enable ipc/ipcd
-dnl ========================================================
-MOZ_ARG_ENABLE_BOOL(ipcd,
-[  --enable-ipcd                      Enable IPC daemon],
-    MOZ_IPCD=1,
-    MOZ_IPCD= )
-
-dnl ========================================================
 dnl disable profile locking
 dnl   do no use this in applications that can have more than
 dnl   one process accessing the profile directory.
 dnl ========================================================
 MOZ_ARG_DISABLE_BOOL(profilelocking,
 [  --disable-profilelocking           Disable profile locking],
     MOZ_PROFILELOCKING=,
     MOZ_PROFILELOCKING=1 )
@@ -7840,21 +7815,18 @@ AC_SUBST(MOZ_FEEDS)
 AC_SUBST(NS_PRINTING)
 
 AC_SUBST(MOZ_JAVAXPCOM)
 AC_SUBST(JAVA_INCLUDE_PATH)
 AC_SUBST(JAVA)
 AC_SUBST(JAVAC)
 AC_SUBST(JAR)
 
-AC_SUBST(MOZ_PROFILESHARING)
 AC_SUBST(MOZ_PROFILELOCKING)
 
-AC_SUBST(MOZ_IPCD)
-
 AC_SUBST(HAVE_XIE)
 AC_SUBST(MOZ_XIE_LIBS)
 AC_SUBST(MOZ_ENABLE_POSTSCRIPT)
 
 AC_SUBST(XPCOM_USE_LEA)
 AC_SUBST(BUILD_STATIC_LIBS)
 AC_SUBST(MOZ_ENABLE_LIBXUL)
 AC_SUBST(ENABLE_TESTS)
--- a/embedding/components/Makefile.in
+++ b/embedding/components/Makefile.in
@@ -50,15 +50,11 @@ DIRS = windowwatcher appstartup find web
 ifdef MOZ_XUL
 ifdef NS_PRINTING
 ifndef WINCE
 DIRS += printingui
 endif
 endif
 endif
 
-ifdef MOZ_PROFILESHARING
-DIRS += profilesharingsetup
-endif
-
 DIRS += build
 
 include $(topsrcdir)/config/rules.mk
--- a/embedding/components/build/Makefile.in
+++ b/embedding/components/build/Makefile.in
@@ -73,20 +73,16 @@ REQUIRES	= js \
 		  content \
 		  layout \
 		  uriloader \
 		  necko \
 		  commandhandler \
 		  xuldoc \
 		  $(NULL)
 
-ifdef MOZ_PROFILESHARING
-REQUIRES += profilesharingsetup
-endif
-
 CPPSRCS		= nsEmbeddingModule.cpp
 
 SHARED_LIBRARY_LIBS = \
 	../windowwatcher/src/$(LIB_PREFIX)windowwatcher_s.$(LIB_SUFFIX) \
 	../appstartup/src/$(LIB_PREFIX)appstartupnotifier_s.$(LIB_SUFFIX) \
 	../find/src/$(LIB_PREFIX)find_s.$(LIB_SUFFIX) \
 	../webbrowserpersist/src/$(LIB_PREFIX)webbrowserpersist_s.$(LIB_SUFFIX) \
 	../commandhandler/src/$(LIB_PREFIX)commandhandler_s.$(LIB_SUFFIX) \
@@ -105,21 +101,16 @@ endif
 LOCAL_INCLUDES	= \
 	-I$(srcdir)/../windowwatcher/src  \
 	-I$(srcdir)/../appstartup/src  \
 	-I$(srcdir)/../find/src  \
 	-I$(srcdir)/../webbrowserpersist/src  \
 	-I$(srcdir)/../commandhandler/src \
 	$(NULL)
 
-ifdef MOZ_PROFILESHARING
-SHARED_LIBRARY_LIBS += $(DIST)/lib/$(LIB_PREFIX)profilesharingsetup_s.$(LIB_SUFFIX)
-LOCAL_INCLUDES += -I$(srcdir)/../profilesharingsetup/src
-endif
-
 ifeq ($(MOZ_WIDGET_TOOLKIT),os2)
 LOCAL_INCLUDES += -I$(srcdir)/../printingui/src/os2 
 endif
 
 ifneq (,$(filter qt gtk2 beos photon, $(MOZ_WIDGET_TOOLKIT)))
 LOCAL_INCLUDES += -I$(srcdir)/../printingui/src/unixshared 
 endif
 
deleted file mode 100644
--- a/embedding/components/profilesharingsetup/Makefile.in
+++ /dev/null
@@ -1,47 +0,0 @@
-# ***** 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) 2003
-# the Initial Developer. All Rights Reserved.
-#
-# Contributor(s):
-#
-# Alternatively, the contents of this file may be used under the terms of
-# either 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 *****
-
-DEPTH		= ../../..
-topsrcdir	= @top_srcdir@
-srcdir		= @srcdir@
-VPATH		= @srcdir@
-
-include $(DEPTH)/config/autoconf.mk
-
-MODULE = profilesharingsetup
-DIRS = public src
-
-include $(topsrcdir)/config/rules.mk
deleted file mode 100644
--- a/embedding/components/profilesharingsetup/public/Makefile.in
+++ /dev/null
@@ -1,53 +0,0 @@
-# ***** 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) 2003
-# the Initial Developer. All Rights Reserved.
-#
-# Contributor(s):
-#
-# Alternatively, the contents of this file may be used under the terms of
-# either 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 *****
-
-DEPTH		= ../../../..
-topsrcdir	= @top_srcdir@
-srcdir		= @srcdir@
-VPATH		= @srcdir@
-
-include $(DEPTH)/config/autoconf.mk
-
-MODULE		= profilesharingsetup
-XPIDL_MODULE	= profilesharingsetup
-GRE_MODULE	= 1
-
-XPIDLSRCS	= \
-		nsIProfileSharingSetup.idl \
-		$(NULL)
-
-include $(topsrcdir)/config/rules.mk
-
deleted file mode 100644
--- a/embedding/components/profilesharingsetup/public/nsIProfileSharingSetup.idl
+++ /dev/null
@@ -1,65 +0,0 @@
-/* ***** 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.
- *
- * The Initial Developer of the Original Code is
- * Netscape Communications Corporation.
- * Portions created by the Initial Developer are Copyright (C) 2003
- * the Initial Developer. All Rights Reserved.
- *
- * Contributor(s):
- *   Conrad Carlen (ccarlen@netscape.com)
- *
- * Alternatively, the contents of this file may be used under the terms of
- * either 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"
-
-[uuid(2f977d57-5485-11d4-87e2-0010a4e75ef2)]
-interface nsIProfileSharingSetup : nsISupports
-{
-  /**
-   * enableSharing must be called by the application in order to use
-   * profile sharing. It should be called as early as possible in the
-   * startup sequence - before any use of profile data. If enabled,
-   * sharing is enabled for all modules that support it.
-   * 
-   * @param aClientName   A non-versioned identifier of the current
-   *                      application within the suite of applications
-   *                      which share this profile. It is used to separate
-   *                      the client's non-shared data from shared data
-   *                      within the profile directory. Example: "browser"
-   *                      or "mail" - not "ProductX 1.3b5"
-   */
-  void enableSharing(in AString aClientName);
-  
-  /**
-   * sharingEnabled and clientName
-   *
-   * Attributes to be used by sharing-enabled components
-   */
-  readonly attribute boolean isSharingEnabled;
-  readonly attribute AString clientName;
-};
deleted file mode 100644
--- a/embedding/components/profilesharingsetup/src/Makefile.in
+++ /dev/null
@@ -1,60 +0,0 @@
-# ***** 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) 2003
-# the Initial Developer. All Rights Reserved.
-#
-# Contributor(s):
-#
-# Alternatively, the contents of this file may be used under the terms of
-# either 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 *****
-
-DEPTH		= ../../../..
-topsrcdir	= @top_srcdir@
-srcdir		= @srcdir@
-VPATH		= @srcdir@
-
-include $(DEPTH)/config/autoconf.mk
-
-MODULE		= profilesharingsetup
-LIBRARY_NAME	= profilesharingsetup_s
-MOZILLA_INTERNAL_API = 1
-
-REQUIRES	= xpcom \
-		  string \
-		  $(NULL)
-
-CPPSRCS		= nsProfileSharingSetup.cpp \
-                  $(NULL)
-
-# we don't want the shared lib, but we want to force the creation of a
-# static lib.
-FORCE_STATIC_LIB = 1
-
-include $(topsrcdir)/config/rules.mk
-
deleted file mode 100644
--- a/embedding/components/profilesharingsetup/src/nsProfileSharingSetup.cpp
+++ /dev/null
@@ -1,86 +0,0 @@
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-/* ***** 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) 2003
- * the Initial Developer. All Rights Reserved.
- *
- * Contributor(s):
- *   Conrad Carlen <ccarlen@netscape.com>
- *
- * Alternatively, the contents of this file may be used under the terms of
- * either 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 "nsProfileSharingSetup.h"
-
-//*****************************************************************************
-// nsProfileSharingSetup::nsProfileSharingSetup
-//*****************************************************************************   
-
-nsProfileSharingSetup::nsProfileSharingSetup() :
-  mSharingGloballyEnabled(PR_FALSE)
-{
-}
-
-nsProfileSharingSetup::~nsProfileSharingSetup()
-{
-}
-
-//*****************************************************************************
-// nsProfileSharingSetup::nsISupports
-//*****************************************************************************   
-
-NS_IMPL_ISUPPORTS1(nsProfileSharingSetup,
-                   nsIProfileSharingSetup)
-
-//*****************************************************************************
-// nsProfileSharingSetup::nsIProfileSharingSetup
-//*****************************************************************************   
-
-/* void enableSharing (in AString aClientName); */
-NS_IMETHODIMP nsProfileSharingSetup::EnableSharing(const nsAString& aClientName)
-{
-  mSharingGloballyEnabled = PR_TRUE;
-  mClientName = aClientName;
-  return NS_OK;
-}
-
-/* readonly attribute boolean isSharingEnabled; */
-NS_IMETHODIMP nsProfileSharingSetup::GetIsSharingEnabled(PRBool *aSharingEnabled)
-{
-  NS_ENSURE_ARG_POINTER(aSharingEnabled);
-  *aSharingEnabled = mSharingGloballyEnabled;
-  return NS_OK;
-}
-
-/* readonly attribute AString clientName; */
-NS_IMETHODIMP nsProfileSharingSetup::GetClientName(nsAString& aClientName)
-{
-  aClientName = mClientName;
-  return NS_OK;
-}
deleted file mode 100644
--- a/embedding/components/profilesharingsetup/src/nsProfileSharingSetup.h
+++ /dev/null
@@ -1,73 +0,0 @@
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-/* ***** 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) 2003
- * the Initial Developer. All Rights Reserved.
- *
- * Contributor(s):
- *   Conrad Carlen <ccarlen@netscape.com>
- *
- * Alternatively, the contents of this file may be used under the terms of
- * either 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 nsProfileSharingSetup_h__
-#define nsProfileSharingSetup_h__
-
-#include "nsIProfileSharingSetup.h"
-#include "nsString.h"
-
-
- // {2f977d58-5485-11d4-87e2-0010a4e75ef2}
-#define NS_PROFILESHARINGSETUP_CID \
-{ 0x2f977d58, 0x5485, 0x11d4, { 0x87, 0xe2, 0x00, 0x10, 0xa4, 0xe7, 0x5e, 0xf2 } }
-
-#define NS_PROFILESHARINGSETUP_CONTRACTID \
-  "@mozilla.org/embedcomp/profile-sharing-setup;1"
-
-// --------------------------------------------------------------------------------------
-// nsProfileSharingSetup
-// --------------------------------------------------------------------------------------
-
-class nsProfileSharingSetup: public nsIProfileSharingSetup
-{
-  NS_DECL_ISUPPORTS
-  NS_DECL_NSIPROFILESHARINGSETUP
-
-public:
-                          nsProfileSharingSetup();
-
-protected:
-  virtual                 ~nsProfileSharingSetup();
-
-protected:
-  PRPackedBool            mSharingGloballyEnabled;
-  nsString                mClientName;
-};
-
-#endif
deleted file mode 100644
--- a/ipc/ipcd/Makefile.in
+++ /dev/null
@@ -1,62 +0,0 @@
-# vim: noexpandtab ts=4 sw=4
-# ***** 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 IPC.
-#
-# The Initial Developer of the Original Code is
-# Netscape Communications Corporation.
-# Portions created by the Initial Developer are Copyright (C) 2002
-# the Initial Developer. All Rights Reserved.
-#
-# Contributor(s):
-#   Darin Fisher <darin@netscape.com>
-#
-# Alternatively, the contents of this file may be used under the terms of
-# either 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 *****
-
-DEPTH		= ../..
-topsrcdir	= @top_srcdir@
-srcdir		= @srcdir@
-VPATH		= @srcdir@
-
-include $(DEPTH)/config/autoconf.mk
-
-MODULE		= ipcd
-
-DIRS		= \
-			util \
-			shared/src \
-			daemon/public \
-			client/public \
-			extensions \
-			client/src \
-			daemon/src \
-			$(NULL)
-
-ifdef ENABLE_TESTS
-DIRS		+= test
-endif
-
-include $(topsrcdir)/config/rules.mk
deleted file mode 100644
--- a/ipc/ipcd/client/public/Makefile.in
+++ /dev/null
@@ -1,59 +0,0 @@
-# vim: noexpandtab ts=4 sw=4
-# ***** 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 IPC.
-#
-# The Initial Developer of the Original Code is
-# Netscape Communications Corporation.
-# Portions created by the Initial Developer are Copyright (C) 2002
-# the Initial Developer. All Rights Reserved.
-#
-# Contributor(s):
-#   Darin Fisher <darin@netscape.com>
-#
-# Alternatively, the contents of this file may be used under the terms of
-# either 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 *****
-
-DEPTH		= ../../../..
-topsrcdir	= @top_srcdir@
-srcdir		= @srcdir@
-VPATH		= @srcdir@
-
-include $(DEPTH)/config/autoconf.mk
-
-MODULE		= ipcd
-
-EXPORTS		= \
-			ipcdclient.h \
-			ipcCID.h \
-			$(NULL)
-
-XPIDLSRCS	= \
-			ipcIService.idl \
-			ipcIMessageObserver.idl \
-			ipcIClientObserver.idl \
-			$(NULL)
-
-include $(topsrcdir)/config/rules.mk
deleted file mode 100644
--- a/ipc/ipcd/client/public/ipcCID.h
+++ /dev/null
@@ -1,53 +0,0 @@
-/* ***** 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 IPC.
- *
- * The Initial Developer of the Original Code is
- * Netscape Communications Corporation.
- * Portions created by the Initial Developer are Copyright (C) 2002
- * the Initial Developer. All Rights Reserved.
- *
- * Contributor(s):
- *   Darin Fisher <darin@netscape.com>
- *
- * Alternatively, the contents of this file may be used under the terms of
- * either 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 ipcCID_h__
-#define ipcCID_h__
-
-#define IPC_SERVICE_CLASSNAME \
-    "ipcService"
-#define IPC_SERVICE_CONTRACTID \
-    "@mozilla.org/ipc/service;1"
-#define IPC_SERVICE_CID                              \
-{ /* 9f12676a-5168-4a08-beb8-edf8a593a1ca */         \
-    0x9f12676a,                                      \
-    0x5168,                                          \
-    0x4a08,                                          \
-    {0xbe, 0xb8, 0xed, 0xf8, 0xa5, 0x93, 0xa1, 0xca} \
-}
-
-#endif // !ipcCID_h__
deleted file mode 100644
--- a/ipc/ipcd/client/public/ipcIClientObserver.idl
+++ /dev/null
@@ -1,51 +0,0 @@
-/* ***** 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 IPC.
- *
- * The Initial Developer of the Original Code is
- * Netscape Communications Corporation.
- * Portions created by the Initial Developer are Copyright (C) 2002
- * the Initial Developer. All Rights Reserved.
- *
- * Contributor(s):
- *   Darin Fisher <darin@netscape.com>
- *
- * Alternatively, the contents of this file may be used under the terms of
- * either 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"
-
-/**
- * ipcIClientObserver
- */
-[scriptable, uuid(42283079-030c-4b13-b069-a08b7ad5eab2)]
-interface ipcIClientObserver : nsISupports
-{
-    const unsigned long CLIENT_UP   = 1;
-    const unsigned long CLIENT_DOWN = 2;
-    
-    void onClientStateChange(in unsigned long aClientID,
-                             in unsigned long aClientState);
-};
deleted file mode 100644
--- a/ipc/ipcd/client/public/ipcIMessageObserver.idl
+++ /dev/null
@@ -1,64 +0,0 @@
-/* ***** 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 IPC.
- *
- * The Initial Developer of the Original Code is
- * Netscape Communications Corporation.
- * Portions created by the Initial Developer are Copyright (C) 2002
- * the Initial Developer. All Rights Reserved.
- *
- * Contributor(s):
- *   Darin Fisher <darin@netscape.com>
- *
- * Alternatively, the contents of this file may be used under the terms of
- * either 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"
-
-/**
- * ipcIMessageObserver
- */
-[scriptable, uuid(e40a4a3c-2dc1-470e-ab7f-5675fe1f1384)]
-interface ipcIMessageObserver : nsISupports
-{
-    /**
-     * @param aSenderID
-     *        the client id of the sender of this message.  if sent by the
-     *        daemon (or a deamon module), then this will have a value of 0.
-     * @param aTarget
-     *        the target of the message, corresponding to the target this
-     *        observer was registered under.  this parameter is passed to allow
-     *        an observer instance to receive messages for more than one target.
-     * @param aData
-     *        the data of the message.
-     * @param aDataLen
-     *        the data length of the message.
-     */
-    void onMessageAvailable(in unsigned long aSenderID,
-                            in nsIDRef       aTarget,
-                           [array, const, size_is(aDataLen)]
-                            in octet         aData,
-                            in unsigned long aDataLen);
-};
deleted file mode 100644
--- a/ipc/ipcd/client/public/ipcIService.idl
+++ /dev/null
@@ -1,228 +0,0 @@
-/* ***** 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 IPC.
- *
- * The Initial Developer of the Original Code is
- * Netscape Communications Corporation.
- * Portions created by the Initial Developer are Copyright (C) 2002
- * the Initial Developer. All Rights Reserved.
- *
- * Contributor(s):
- *   Darin Fisher <darin@netscape.com>
- *
- * Alternatively, the contents of this file may be used under the terms of
- * either 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 ipcIMessageObserver;
-interface ipcIClientObserver;
-
-/**
- * ipcIService
- *
- * the IPC service provides the means to communicate with an external IPC
- * daemon and/or other mozilla-based applications on the same physical system.
- * the IPC daemon hosts modules (some builtin and others dynamically loaded)
- * with which applications may interact.
- *
- * at application startup, the IPC service will attempt to establish a
- * connection with the IPC daemon.  the IPC daemon will be automatically
- * started if necessary.  when a connection has been established, the IPC
- * service will enumerate the "ipc-startup-category" and broadcast an
- * "ipc-startup" notification using the observer service.
- *
- * when the connection to the IPC daemon is closed, an "ipc-shutdown"
- * notification will be broadcast.
- *
- * each client has a name.  the client name need not be unique across all
- * clients, but it is usually good if it is.  the IPC service does not require
- * unique names.  instead, the IPC daemon assigns each client a unique ID that
- * is good for the current "session."  clients can query other clients by name
- * or by ID.  the IPC service supports forwarding messages from one client to
- * another via the IPC daemon.
- *
- * for performance reasons, this system should not be used to transfer large
- * amounts of data.  instead, applications may choose to utilize shared memory,
- * and rely on the IPC service for synchronization and small message transfer
- * only.
- */
-[scriptable, uuid(53d3e3a7-528f-4b09-9eab-9416272568c0)]
-interface ipcIService : nsISupports
-{
-    /**************************************************************************
-     * properties of this process
-     */
-
-    /**
-     * returns the "client ID" assigned to this process by the IPC daemon.
-     *
-     * @throws NS_ERROR_NOT_AVAILABLE if no connection to the IPC daemon.
-     */
-    readonly attribute unsigned long ID;
-
-    /**
-     * this process can appear under several client names.  use the following
-     * methods to add or remove names for this process.
-     *
-     * for example, the mozilla browser might have the primary name "mozilla",
-     * but it could also register itself under the names "browser", "mail",
-     * "news", "addrbook", etc.  other IPC clients can then query the IPC
-     * daemon for the client named "mail" in order to talk with a mail program.
-     *
-     * XXX An IPC client name resembles a XPCOM contract ID.
-     */
-    void addName(in string aName);
-    void removeName(in string aName);
-
-    /**
-     * add a new observer of client status change notifications.
-     */
-    void addClientObserver(in ipcIClientObserver aObserver);
-
-    /**
-     * remove an observer of client status change notifications.
-     */
-    void removeClientObserver(in ipcIClientObserver aObserver);
-
-    /**************************************************************************
-     * client query methods
-     */
-
-    /**
-     * resolve the given client name to the id of a connected client.  this
-     * involves a round trip to the daemon, and as a result the calling thread
-     * may block on this function call while waiting for the daemon to respond.
-     */
-    unsigned long resolveClientName(in string aName);
-
-
-    /**
-     * tests whether a particular client is connected to the IPC daemon.
-     */
-    boolean clientExists(in unsigned long aClientID);
-
-
-    // XXX need other functions to enumerate clients, clients implementing targets, etc.
-    // enumerator getClients();
-    // enumerator getClientsSupportingTarget(in nsIDRef aTarget);
-    // enumerator getClientNames(in unsigned long aClientID);
-    // enumerator getClientTargets(in unsigned long aClientID);
-
-
-    /**************************************************************************
-     * message methods
-     */
-
-    /**
-     * set a message observer for a particular message target.
-     *
-     * @param aTarget
-     *        the message target being observed.  any existing observer will
-     *        be replaced.
-     * @param aObserver
-     *        the message observer to receive incoming messages for the
-     *        specified target.  pass null to remove the existing observer.
-     * @param aOnCurrentThread
-     *        if true, then the message observer will be called on the same
-     *        thread that calls defineTarget.  otherwise, aObserver will be
-     *        called on a background thread.
-     */
-    void defineTarget(in nsIDRef             aTarget,
-                      in ipcIMessageObserver aObserver,
-                      in boolean             aOnCurrentThread);
-
-    /**
-     * send message asynchronously to a client or a module in the IPC daemon.
-     * there is no guarantee that the message will be delivered.
-     *
-     * @param aClientID
-     *        the client ID of the foreign application that should receive this
-     *        message.  pass 0 to send a message to a module in the IPC daemon.
-     * @param aTarget
-     *        the target of the message.  if aClientID is 0, then this is the
-     *        ID of the daemon module that should receive this message.
-     * @param aData
-     *        the message data.
-     * @param aDataLen
-     *        the message length.
-     */
-    void sendMessage(in unsigned long aReceiverID,
-                     in nsIDRef       aTarget,
-                    [array, const, size_is(aDataLen)]
-                     in octet         aData,
-                     in unsigned long aDataLen);
-
-    /**
-     * block the calling thread until a matching message is received.
-     *
-     * @param aSenderID
-     *        pass 0 to wait for a message from the daemon.  pass PR_UINT32_MAX
-     *        to wait for a message from any source.  otherwise, pass a client
-     *        id to wait for a message from that particular client.
-     * @param aTarget
-     *        wait for a message to be delivered to this target.
-     * @param aObserver
-     *        this observer's OnMessageAvailable method is called when a
-     *        matching message is available.  pass null to use the default
-     *        observer associated with aTarget.
-     * @param aTimeout
-     *        indicates maximum length of time in milliseconds that this
-     *        function may block the calling thread.
-     *
-     * @throws IPC_ERROR_WOULD_BLOCK if the timeout expires.
-     *
-     * the observer's OnMessageAvailable method may throw IPC_WAIT_NEXT_MESSAGE
-     * to indicate that it does not wish to handle the message that it was
-     * given, and that it will wait to be called with the next message.  this
-     * enables the observer to keep messages in the queue that do not match the
-     * desired message.  messages that remain in the queue will be dispatched
-     * asynchronously to the default message handler after waitMessage finishes.
-     *
-     * NOTE: this function may hang the calling thread until a matching message
-     * is received, so use it with caution.
-     */
-    void waitMessage(in unsigned long       aSenderID,
-                     in nsIDRef             aTarget,
-                     in ipcIMessageObserver aObserver,
-                     in unsigned long       aTimeout);
-
-    /**
-     * Call this method to disable the default message observer for a target.
-     */
-    void disableMessageObserver(in nsIDRef aTarget);
-
-    /**
-     * Call this method to re-enable the default message observer for a target.
-     */
-    void enableMessageObserver(in nsIDRef aTarget);
-};
-
-%{C++
-// category and observer event defines (XXX not yet implemented)
-#define IPC_SERVICE_STARTUP_CATEGORY "ipc-startup-category"
-#define IPC_SERVICE_STARTUP_TOPIC    "ipc-startup"
-#define IPC_SERVICE_SHUTDOWN_TOPIC   "ipc-shutdown"
-%}
deleted file mode 100644
--- a/ipc/ipcd/client/public/ipcdclient.h
+++ /dev/null
@@ -1,287 +0,0 @@
-/* ***** 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 IPC.
- *
- * The Initial Developer of the Original Code is IBM Corporation.
- * Portions created by the Initial Developer are Copyright (C) 2004
- * the Initial Developer. All Rights Reserved.
- *
- * Contributor(s):
- *   Darin Fisher <darin@meer.net>
- *
- * Alternatively, the contents of this file may be used under the terms of
- * either 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 ipcdclient_h__
-#define ipcdclient_h__
-
-/*****************************************************************************
- * This file provides a client-side API to the IPC daemon.
- *
- * This API can be used to communicate with other clients of the IPC daemon
- * as well as modules running inside the IPC daemon.
- *
- * This API is meant to be used only on the application's main thread.  It is
- * assumed that callbacks can be dispatched via the main thread's event queue.
- */
-
-#include "nscore.h"
-#include "nsID.h"
-#include "nsError.h"
-#include "ipcIMessageObserver.h"
-#include "ipcIClientObserver.h"
-
-/* This API is only provided for the extensions compiled into the IPCDC
- * library, hence this API is hidden in the final DSO. */
-#define IPC_METHOD NS_HIDDEN_(nsresult)
-
-/* This value can be used to represent the client id of any client connected
- * to the IPC daemon. */
-#define IPC_SENDER_ANY PR_UINT32_MAX
-
-/* This error code can only be returned by OnMessageAvailable, when called by
- * IPC_WaitMessage.  See IPC_WaitMessage for a description of how this error
- * code may be used. */
-#define IPC_WAIT_NEXT_MESSAGE \
-  NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_GENERAL, 10)
-
-/* This error code is returned by IPC_WaitMessage under certain conditions. */
-#define IPC_ERROR_WOULD_BLOCK NS_BASE_STREAM_WOULD_BLOCK
-
-/*****************************************************************************
- * Initialization and Shutdown
- */
-
-// XXX limit these to the main thread, and call them from our module's ctor/dtor?
-
-/**
- * Connects this process to the IPC daemon and initializes it for use as a
- * client of the IPC daemon.  This function must be called once before any
- * other methods defined in this file can be used.
- *
- * @returns NS_ERROR_ALREADY_INITIALIZED if IPC_Shutdown was not called since
- * the last time IPC_Init was called.
- */
-IPC_METHOD IPC_Init();
-
-/**
- * Disconnects this process from the IPC daemon.  After this function is
- * called, no other methods in this file except for IPC_Init may be called.
- *
- * @returns NS_ERROR_NOT_INITIALIZED if IPC_Init has not been called or if
- * IPC_Init did not return a success code.
- */
-IPC_METHOD IPC_Shutdown();
-
-
-/*****************************************************************************
- * The core messaging API
- */
-
-/**
- * Call this method to define a message target.  A message target is defined
- * by a UUID and a message observer.  This observer is notified asynchronously
- * whenever a message is sent to this target in this process.
- *
- * This function has three main effects:
- *  o  If the message target is already defined, then this function simply
- *     resets its message observer.
- *  o  If the message target is not already defined, then the message target
- *     is defined and the IPC daemon is notified of the existance of this
- *     message target.
- *  o  If null is passed for the message observer, then the message target is
- *     removed, and the daemon is notified of the removal of this message target.
- *
- * If aOnCurrentThread is true, then notifications to the observer will occur
- * on the current thread.  This means that there must be a nsIEventTarget
- * associated with the calling thread.  If aOnCurrentThread is false, then
- * notifications to the observer will occur on a background thread.  In which
- * case, the observer must be threadsafe.
- */
-IPC_METHOD IPC_DefineTarget(
-  const nsID          &aTarget,
-  ipcIMessageObserver *aObserver,
-  PRBool               aOnCurrentThread = PR_TRUE
-);
-
-/**
- * Call this method to temporarily disable the message observer configured
- * for a message target.
- */
-IPC_METHOD IPC_DisableMessageObserver(
-  const nsID          &aTarget
-);
-
-/**
- * Call this method to re-enable the message observer configured for a
- * message target.
- */
-IPC_METHOD IPC_EnableMessageObserver(
-  const nsID          &aTarget
-);
-
-/**
- * This function sends a message to the IPC daemon asynchronously.  If
- * aReceiverID is non-zero, then the message is forwarded to the client
- * corresponding to that identifier.
- *
- * If there is no client corresponding to aReceiverID, then the IPC daemon will
- * simply drop the message.
- */
-IPC_METHOD IPC_SendMessage(
-  PRUint32             aReceiverID,
-  const nsID          &aTarget,
-  const PRUint8       *aData,
-  PRUint32             aDataLen
-);
-
-/**
- * This function blocks the calling thread until a message for the given target
- * is received (optionally from the specified client).
- *
- * The aSenderID parameter is interpreted as follows:
- *  o  If aSenderID is 0, then this function waits for a message to be sent by
- *     the IPC daemon.
- *  o  If aSenderID is IPC_SENDER_ANY, then this function waits for a message
- *     to be sent from any source.
- *  o  Otherwise, this function waits for a message to be sent by the client
- *     with ID given by aSenderID.  If aSenderID does not identify a valid
- *     client, then this function will return an error.
- *
- * The aObserver parameter is interpreted as follows:
- *  o  If aObserver is null, then the default message observer for the target
- *     is invoked when the next message is received.
- *  o  Otherwise, aObserver will be inovked when the next message is received.
- *
- * The aTimeout parameter is interpreted as follows:
- *  o  If aTimeout is PR_INTERVAL_NO_TIMEOUT, then this function will block
- *     until a matching message is received.
- *  o  If aTimeout is PR_INTERVAL_NO_WAIT, then this function will only inspect
- *     the current queue of messages.  If no matching message is found, then
- *     IPC_ERROR_WOULD_BLOCK is returned.
- *  o  Otherwise, aTimeout specifies the maximum amount of time to wait for a
- *     matching message to be received.  If no matching message is found after
- *     the timeout expires, then IPC_ERROR_WOULD_BLOCK is returned.
- *
- * If aObserver's OnMessageAvailable function returns IPC_WAIT_NEXT_MESSAGE,
- * then the function will continue blocking until the next matching message
- * is received.  Bypassed messages will be dispatched to the default message
- * observer when the event queue, associated with the thread that called
- * IPC_DefineTarget, is processed.
- *
- * This function runs the risk of hanging the calling thread indefinitely if
- * no matching message is ever received.
- */
-IPC_METHOD IPC_WaitMessage(
-  PRUint32             aSenderID,
-  const nsID          &aTarget,
-  ipcIMessageObserver *aObserver = nsnull,
-  PRIntervalTime       aTimeout = PR_INTERVAL_NO_TIMEOUT
-);
-
-/*****************************************************************************/
-
-/**
- * Returns the "ClientID" of the current process.
- */
-IPC_METHOD IPC_GetID(
-  PRUint32 *aClientID
-);
-
-/**
- * Adds a new name for the current process.  The IPC daemon is notified of this
- * change, which allows other processes to discover this process by the given
- * name.
- */
-IPC_METHOD IPC_AddName(
-  const char *aName
-);
-
-/**
- * Removes a name associated with the current process.
- */
-IPC_METHOD IPC_RemoveName(
-  const char *aName
-);
-
-/**
- * Adds client observer.  Will be called on the main thread.
- */
-IPC_METHOD IPC_AddClientObserver(
-  ipcIClientObserver *aObserver
-);
-
-/**
- * Removes client observer.
- */
-IPC_METHOD IPC_RemoveClientObserver(
-  ipcIClientObserver *aObserver
-);
-
-/**
- * Resolves the given client name to a client ID of a process connected to
- * the IPC daemon.
- */
-IPC_METHOD IPC_ResolveClientName(
-  const char *aName,
-  PRUint32   *aClientID
-);
-
-/**
- * Tests whether the client is connected to the IPC daemon.
- */
-IPC_METHOD IPC_ClientExists(
-  PRUint32  aClientID,
-  PRBool   *aResult
-);
-
-/*****************************************************************************/
-
-/**
- * This class can be used to temporarily disable the default message observer
- * defined for a particular message target.
- */
-class ipcDisableMessageObserverForScope
-{
-public:
-  ipcDisableMessageObserverForScope(const nsID &aTarget)
-    : mTarget(aTarget)
-  {
-    IPC_DisableMessageObserver(mTarget);
-  }
-
-  ~ipcDisableMessageObserverForScope()
-  {
-    IPC_EnableMessageObserver(mTarget);
-  }
-
-private:
-  const nsID &mTarget;
-};
-
-#define IPC_DISABLE_MESSAGE_OBSERVER_FOR_SCOPE(_t) \
-  ipcDisableMessageObserverForScope ipc_dmo_for_scope##_t(_t)
-
-#endif /* ipcdclient_h__ */
deleted file mode 100644
--- a/ipc/ipcd/client/src/Makefile.in
+++ /dev/null
@@ -1,102 +0,0 @@
-# vim: noexpandtab ts=4 sw=4
-# ***** 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 IPC.
-#
-# The Initial Developer of the Original Code is
-# Netscape Communications Corporation.
-# Portions created by the Initial Developer are Copyright (C) 2002
-# the Initial Developer. All Rights Reserved.
-#
-# Contributor(s):
-#   Darin Fisher <darin@netscape.com>
-#
-# Alternatively, the contents of this file may be used under the terms of
-# either 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 *****
-
-DEPTH		= ../../../..
-topsrcdir	= @top_srcdir@
-srcdir		= @srcdir@
-VPATH		= @srcdir@
-
-include $(DEPTH)/config/autoconf.mk
-
-MODULE			= ipcd
-LIBRARY_NAME	= ipcdc
-EXPORT_LIBRARY	= 1
-IS_COMPONENT	= 1
-MODULE_NAME		= ipcdclient
-LIBXUL_LIBRARY = 1
-
-REQUIRES	= \
-            xpcom \
-            string \
-            $(NULL)
-
-CPPSRCS		= \
-            ipcdclient.cpp \
-            ipcService.cpp \
-            ipcModuleFactory.cpp \
-            $(NULL)
-
-ifeq ($(OS_ARCH),WINNT)
-CPPSRCS +=  ipcConnectionWin.cpp
-else
-ifeq ($(OS_ARCH),BeOS)
-CPPSRCS +=  ipcConnectionStub.cpp
-else
-CPPSRCS +=  ipcConnectionUnix.cpp
-endif
-endif
-
-LOCAL_INCLUDES = \
-            -I$(srcdir)/../../shared/src \
-            -I$(srcdir)/../../extensions/lock/src \
-            -I$(srcdir)/../../extensions/transmngr/src \
-            -I$(srcdir)/../../extensions/transmngr/common \
-            $(NULL)
-
-SHARED_LIBRARY_LIBS = \
-			$(DIST)/lib/$(LIB_PREFIX)ipcdshared_s.$(LIB_SUFFIX) \
-			$(DIST)/lib/$(LIB_PREFIX)ipcdlock_s.$(LIB_SUFFIX) \
-			$(DIST)/lib/$(LIB_PREFIX)transmgr_s.$(LIB_SUFFIX) \
-			$(DIST)/lib/$(LIB_PREFIX)transmgrcom_s.$(LIB_SUFFIX) \
-			$(NULL)
-
-ifneq ($(BUILD_DCONNECT),)
-DEFINES				+= -DBUILD_DCONNECT
-LOCAL_INCLUDES		+= -I$(srcdir)/../../extensions/dconnect/src
-SHARED_LIBRARY_LIBS	+= $(DIST)/lib/$(LIB_PREFIX)ipcddconnect_s.$(LIB_SUFFIX) \
-					   $(DIST)/lib/$(LIB_PREFIX)ipcdutil_s.$(LIB_SUFFIX) \
-					   $(NULL)
-endif
-
-EXTRA_DSO_LDOPTS = \
-			$(LIBS_DIR) \
-			$(EXTRA_DSO_LIBS) \
-			$(MOZ_COMPONENT_LIBS) \
-			$(NULL)
-
-include $(topsrcdir)/config/rules.mk
deleted file mode 100644
--- a/ipc/ipcd/client/src/ipcConnection.h
+++ /dev/null
@@ -1,147 +0,0 @@
-/* vim:set ts=2 sw=2 et cindent: */
-/* ***** 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 IPC.
- *
- * The Initial Developer of the Original Code is IBM Corporation.
- * Portions created by IBM Corporation are Copyright (C) 2003
- * IBM Corporation. All Rights Reserved.
- *
- * Contributor(s):
- *   Darin Fisher <darin@meer.net>
- *
- * Alternatively, the contents of this file may be used under the terms of
- * either 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 ipcConnection_h__
-#define ipcConnection_h__
-
-#include "nscore.h"
-
-class ipcMessage;
-
-#define IPC_METHOD_PRIVATE_(type)   NS_HIDDEN_(type)
-#define IPC_METHOD_PRIVATE          IPC_METHOD_PRIVATE_(nsresult)
-
-/* ------------------------------------------------------------------------- */
-/* Platform specific IPC connection API.
- */
-
-typedef void (* ipcCallbackFunc)(void *);
-
-/**
- * IPC_Connect
- *
- * This function causes a connection to the IPC daemon to be established.
- * If a connection already exists, then this function will be ignored.
- *
- * @param daemonPath
- *        Specifies the path to the IPC daemon executable.
- *
- * NOTE: This function must be called on the main thread.
- */
-IPC_METHOD_PRIVATE IPC_Connect(const char *daemonPath);
-
-/**
- * IPC_Disconnect
- *
- * This function causes a connection to the IPC daemon to be closed.  Any
- * unsent messages (IPC_SendMsg puts messages on a queue) will be sent to the
- * IPC daemon before the connection is closed.
- *
- * NOTE: This function must be called on the main thread.
- */
-IPC_METHOD_PRIVATE IPC_Disconnect();
-
-/**
- * IPC_SendMsg
- *
- * This function sends a message to the IPC daemon.  Typically, the message
- * is put on a queue, to be delivered asynchronously to the IPC daemon.  The
- * ipcMessage object will be deleted when IPC_SendMsg is done with it.  The
- * caller must not touch |msg| after passing it to IPC_SendMsg.
- *
- * IPC_SendMsg cannot be called before IPC_Connect or after IPC_Disconnect.
- *
- * NOTE: This function may be called on any thread.
- */
-IPC_METHOD_PRIVATE IPC_SendMsg(ipcMessage *msg);
-
-/**
- * IPC_DoCallback
- *
- * This function executes a callback function on the same background thread
- * that calls IPC_OnConnectionEnd and IPC_OnMessageAvailable.
- *
- * If this function succeeds, then the caller is guaranteed that |func| will
- * be called.  This guarantee is important because it allows the caller to
- * free any memory associated with |arg| once |func| has been called.
- *
- * NOTE: This function may be called on any thread.
- */
-IPC_METHOD_PRIVATE IPC_DoCallback(ipcCallbackFunc func, void *arg);
-
-/* ------------------------------------------------------------------------- */
-/* Cross-platform IPC connection methods.
- */
-
-/**
- * IPC_SpawnDaemon
- *
- * This function launches the IPC daemon process.  It is called by the platform
- * specific IPC_Connect implementation.  It should not return until the daemon
- * process is ready to receive a client connection or an error occurs.
- *
- * @param daemonPath
- *        Specifies the path to the IPC daemon executable.
- */
-IPC_METHOD_PRIVATE IPC_SpawnDaemon(const char *daemonPath);
-
-/* ------------------------------------------------------------------------- */
-/* IPC connection callbacks (not implemented by the connection code).
- *
- * NOTE: These functions execute on a background thread!!
- */
-
-/**
- * IPC_OnConnectionEnd
- *
- * This function is called whenever the connection to the IPC daemon has been
- * terminated.  If terminated due to an abnormal error, then the error will be
- * described by the |error| parameter.  If |error| is NS_OK, then it means the
- * connection was closed in response to a call to IPC_Disconnect.
- */
-IPC_METHOD_PRIVATE_(void) IPC_OnConnectionEnd(nsresult error);
-
-/**
- * IPC_OnMessageAvailable
- *
- * This function is called whenever an incoming message is read from the IPC
- * daemon.  The ipcMessage object, |msg|, must be deleted by the implementation
- * of IPC_OnMessageAvailable when the object is no longer needed.
- */
-IPC_METHOD_PRIVATE_(void) IPC_OnMessageAvailable(ipcMessage *msg);
-
-#endif // ipcConnection_h__
deleted file mode 100644
--- a/ipc/ipcd/client/src/ipcConnectionStub.cpp
+++ /dev/null
@@ -1,70 +0,0 @@
-/* vim:set ts=2 sw=2 et cindent: */
-/* ***** 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 IPC.
- *
- * The Initial Developer of the Original Code is IBM Corporation.
- * Portions created by IBM Corporation are Copyright (C) 2003
- * IBM Corporation. All Rights Reserved.
- *
- * Contributor(s):
- *   Darin Fisher <darin@meer.net>
- *
- * Alternatively, the contents of this file may be used under the terms of
- * either 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 "ipcConnection.h"
-#include "nsError.h"
-
-//-----------------------------------------------------------------------------
-// use this file as a template to add client-side IPC connectivity.
-// 
-// NOTE: if your platform supports local domain TCP sockets, then you should
-//       be able to make use of ipcConnectionUnix.cpp.
-//-----------------------------------------------------------------------------
-
-nsresult
-IPC_Connect(const char *daemonPath)
-{
-    return NS_ERROR_NOT_IMPLEMENTED;
-}
-
-nsresult
-IPC_Disconnect()
-{
-    return NS_ERROR_NOT_IMPLEMENTED;
-}
-
-nsresult
-IPC_SendMsg(ipcMessage *msg)
-{
-    return NS_ERROR_NOT_IMPLEMENTED;
-}
-
-nsresult
-IPC_DoCallback(ipcCallbackFunc func, void *arg)
-{
-    return NS_ERROR_NOT_IMPLEMENTED;
-}
deleted file mode 100644
--- a/ipc/ipcd/client/src/ipcConnectionUnix.cpp
+++ /dev/null
@@ -1,589 +0,0 @@
-/* vim:set ts=2 sw=2 et cindent: */
-/* ***** 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 IPC.
- *
- * The Initial Developer of the Original Code is IBM Corporation.
- * Portions created by IBM Corporation are Copyright (C) 2003
- * IBM Corporation. All Rights Reserved.
- *
- * Contributor(s):
- *   Darin Fisher <darin@meer.net>
- *
- * Alternatively, the contents of this file may be used under the terms of
- * either 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 "private/pprio.h"
-#include "prerror.h"
-#include "prthread.h"
-#include "prlock.h"
-#include "prlog.h" // for PR_ASSERT (we don't actually use NSPR logging)
-#include "prio.h"
-
-#include "ipcConnection.h"
-#include "ipcMessageQ.h"
-#include "ipcConfig.h"
-#include "ipcLog.h"
-
-
-//-----------------------------------------------------------------------------
-// NOTE: this code does not need to link with anything but NSPR.  that is by
-//       design, so it can be easily reused in other projects that want to 
-//       talk with mozilla's IPC daemon, but don't want to depend on xpcom.
-//       we depend at most on some xpcom header files, but no xpcom runtime
-//       symbols are used.
-//-----------------------------------------------------------------------------
-
-
-// single user systems, like OS/2, don't need these security checks.
-#ifndef XP_OS2
-#define IPC_SKIP_SECURITY_CHECKS
-#endif
-
-#ifndef IPC_SKIP_SECURITY_CHECKS
-#include <unistd.h>
-#include <sys/stat.h>
-#endif
-
-static PRStatus
-DoSecurityCheck(PRFileDesc *fd, const char *path)
-{
-#ifndef IPC_SKIP_SECURITY_CHECKS
-    //
-    // now that we have a connected socket; do some security checks on the
-    // file descriptor.
-    //
-    //   (1) make sure owner matches
-    //   (2) make sure permissions match expected permissions
-    //
-    // if these conditions aren't met then bail.
-    //
-    int unix_fd = PR_FileDesc2NativeHandle(fd);  
-
-    struct stat st;
-    if (fstat(unix_fd, &st) == -1) {
-        LOG(("stat failed"));
-        return PR_FAILURE;
-    }
-
-    if (st.st_uid != getuid() && st.st_uid != geteuid()) {
-        //
-        // on OSX 10.1.5, |fstat| has a bug when passed a file descriptor to
-        // a socket.  it incorrectly returns a UID of 0.  however, |stat|
-        // succeeds, but using |stat| introduces a race condition.
-        //
-        // XXX come up with a better security check.
-        //
-        if (st.st_uid != 0) {
-            LOG(("userid check failed"));
-            return PR_FAILURE;
-        }
-        if (stat(path, &st) == -1) {
-            LOG(("stat failed"));
-            return PR_FAILURE;
-        }
-        if (st.st_uid != getuid() && st.st_uid != geteuid()) {
-            LOG(("userid check failed"));
-            return PR_FAILURE;
-        }
-    }
-#endif
-    return PR_SUCCESS;
-}
-
-//-----------------------------------------------------------------------------
-
-struct ipcCallback : public ipcListNode<ipcCallback>
-{
-  ipcCallbackFunc  func;
-  void            *arg;
-};
-
-typedef ipcList<ipcCallback> ipcCallbackQ;
-
-//-----------------------------------------------------------------------------
-
-struct ipcConnectionState
-{
-  PRLock      *lock;
-  PRPollDesc   fds[2];
-  ipcCallbackQ callback_queue;
-  ipcMessageQ  send_queue;
-  PRUint32     send_offset; // amount of send_queue.First() already written.
-  ipcMessage  *in_msg;
-  PRBool       shutdown;
-};
-
-#define SOCK 0
-#define POLL 1
-
-static void
-ConnDestroy(ipcConnectionState *s)
-{
-  if (s->lock)
-    PR_DestroyLock(s->lock);  
-
-  if (s->fds[SOCK].fd)
-    PR_Close(s->fds[SOCK].fd);
-
-  if (s->fds[POLL].fd)
-    PR_DestroyPollableEvent(s->fds[POLL].fd);
-
-  if (s->in_msg)
-    delete s->in_msg;
-
-  s->send_queue.DeleteAll();
-  delete s;
-}
-
-static ipcConnectionState *
-ConnCreate(PRFileDesc *fd)
-{
-  ipcConnectionState *s = new ipcConnectionState;
-  if (!s)
-    return NULL;
-
-  s->lock = PR_NewLock();
-  s->fds[SOCK].fd = NULL;
-  s->fds[POLL].fd = PR_NewPollableEvent();
-  s->send_offset = 0;
-  s->in_msg = NULL;
-  s->shutdown = PR_FALSE;
-
-  if (!s->lock || !s->fds[1].fd)
-  {
-    ConnDestroy(s);
-    return NULL;
-  }
-
-  // store this only if we are going to succeed.
-  s->fds[SOCK].fd = fd;
-
-  return s;
-}
-
-static nsresult
-ConnRead(ipcConnectionState *s)
-{
-  char buf[1024];
-  nsresult rv = NS_OK;
-  PRInt32 n;
-
-  do
-  {
-    n = PR_Read(s->fds[SOCK].fd, buf, sizeof(buf));
-    if (n < 0)
-    {
-      PRErrorCode err = PR_GetError();
-      if (err == PR_WOULD_BLOCK_ERROR)
-      {
-        // socket is empty... we need to go back to polling.
-        break;
-      }
-      LOG(("PR_Read returned failure [err=%d]\n", err));
-      rv = NS_ERROR_UNEXPECTED;
-    }
-    else if (n == 0)
-    {
-      LOG(("PR_Read returned EOF\n"));
-      rv = NS_ERROR_UNEXPECTED;
-    }
-    else
-    {
-      const char *pdata = buf;
-      while (n)
-      {
-        PRUint32 bytesRead;
-        PRBool complete;
-
-        if (!s->in_msg)
-        {
-          s->in_msg = new ipcMessage;
-          if (!s->in_msg)
-          {
-            rv = NS_ERROR_OUT_OF_MEMORY;
-            break;
-          }
-        }
-
-        if (s->in_msg->ReadFrom(pdata, n, &bytesRead, &complete) != PR_SUCCESS)
-        {
-          LOG(("error reading IPC message\n"));
-          rv = NS_ERROR_UNEXPECTED;
-          break;
-        }
-
-        PR_ASSERT(PRUint32(n) >= bytesRead);
-        n -= bytesRead;
-        pdata += bytesRead;
-
-        if (complete)
-        {
-          // protect against weird re-entrancy cases...
-          ipcMessage *m = s->in_msg;
-          s->in_msg = NULL;
-
-          IPC_OnMessageAvailable(m);
-        }
-      }
-    }
-  }
-  while (NS_SUCCEEDED(rv));
-
-  return rv;
-}
-
-static nsresult
-ConnWrite(ipcConnectionState *s)
-{
-  nsresult rv = NS_OK;
-
-  PR_Lock(s->lock);
-
-  // write one message and then return.
-  if (s->send_queue.First())
-  {
-    PRInt32 n = PR_Write(s->fds[SOCK].fd,
-                         s->send_queue.First()->MsgBuf() + s->send_offset,
-                         s->send_queue.First()->MsgLen() - s->send_offset);
-    if (n <= 0)
-    {
-      PRErrorCode err = PR_GetError();
-      if (err == PR_WOULD_BLOCK_ERROR)
-      {
-        // socket is full... we need to go back to polling.
-      }
-      else
-      {
-        LOG(("error writing to socket [err=%d]\n", err));
-        rv = NS_ERROR_UNEXPECTED;
-      }
-    }
-    else
-    {
-      s->send_offset += n;
-      if (s->send_offset == s->send_queue.First()->MsgLen())
-      {
-        s->send_queue.DeleteFirst();
-        s->send_offset = 0;
-
-        // if the send queue is empty, then we need to stop trying to write.
-        if (s->send_queue.IsEmpty())
-          s->fds[SOCK].in_flags &= ~PR_POLL_WRITE;
-      }
-    }
-  }
-
-  PR_Unlock(s->lock);
-  return rv;
-}
-
-static void
-ConnThread(void *arg)
-{
-  PRInt32 num;
-  nsresult rv = NS_OK;
-
-  ipcConnectionState *s = (ipcConnectionState *) arg;
-
-  // we monitor two file descriptors in this thread.  the first (at index 0) is
-  // the socket connection with the IPC daemon.  the second (at index 1) is the
-  // pollable event we monitor in order to know when to send messages to the
-  // IPC daemon.
-
-  s->fds[SOCK].in_flags = PR_POLL_READ;
-  s->fds[POLL].in_flags = PR_POLL_READ;
-
-  while (NS_SUCCEEDED(rv))
-  {
-    s->fds[SOCK].out_flags = 0;
-    s->fds[POLL].out_flags = 0;
-
-    //
-    // poll on the IPC socket and NSPR pollable event
-    //
-    num = PR_Poll(s->fds, 2, PR_INTERVAL_NO_TIMEOUT);
-    if (num > 0)
-    {
-      ipcCallbackQ cbs_to_run;
-
-      // check if something has been added to the send queue.  if so, then
-      // acknowledge pollable event (wait should not block), and configure
-      // poll flags to find out when we can write.
-
-      if (s->fds[POLL].out_flags & PR_POLL_READ)
-      {
-        PR_WaitForPollableEvent(s->fds[POLL].fd);
-        PR_Lock(s->lock);
-
-        if (!s->send_queue.IsEmpty())
-          s->fds[SOCK].in_flags |= PR_POLL_WRITE;
-
-        if (!s->callback_queue.IsEmpty())
-          s->callback_queue.MoveTo(cbs_to_run);
-
-        PR_Unlock(s->lock);
-      }
-
-      // check if we can read...
-      if (s->fds[SOCK].out_flags & PR_POLL_READ)
-        rv = ConnRead(s);
-
-      // check if we can write...
-      if (s->fds[SOCK].out_flags & PR_POLL_WRITE)
-        rv = ConnWrite(s);
-
-      // check if we have callbacks to run
-      while (!cbs_to_run.IsEmpty())
-      {
-        ipcCallback *cb = cbs_to_run.First();
-        (cb->func)(cb->arg);
-        cbs_to_run.DeleteFirst();
-      }
-
-      // check if we should exit this thread.  delay processing a shutdown
-      // request until after all queued up messages have been sent and until
-      // after all queued up callbacks have been run.
-      PR_Lock(s->lock);
-      if (s->shutdown && s->send_queue.IsEmpty() && s->callback_queue.IsEmpty())
-        rv = NS_ERROR_ABORT;
-      PR_Unlock(s->lock);
-    }
-    else
-    {
-      LOG(("PR_Poll returned an error\n"));
-      rv = NS_ERROR_UNEXPECTED;
-    }
-  }
-
-  // notify termination of the IPC connection
-  if (rv == NS_ERROR_ABORT)
-    rv = NS_OK;
-  IPC_OnConnectionEnd(rv);
-
-  LOG(("IPC thread exiting\n"));
-}
-
-//-----------------------------------------------------------------------------
-// IPC connection API
-//-----------------------------------------------------------------------------
-
-static ipcConnectionState *gConnState = NULL;
-static PRThread *gConnThread = NULL;
-
-#ifdef DEBUG
-static PRThread *gMainThread = NULL;
-#endif
-
-nsresult
-TryConnect(PRFileDesc **result)
-{
-  PRFileDesc *fd;
-  PRNetAddr addr;
-  PRSocketOptionData opt;
-  nsresult rv = NS_ERROR_FAILURE;
-
-  fd = PR_OpenTCPSocket(PR_AF_LOCAL);
-  if (!fd)
-    goto end;
-
-  addr.local.family = PR_AF_LOCAL;
-  IPC_GetDefaultSocketPath(addr.local.path, sizeof(addr.local.path));
-
-  // blocking connect... will fail if no one is listening.
-  if (PR_Connect(fd, &addr, PR_INTERVAL_NO_TIMEOUT) == PR_FAILURE)
-    goto end;
-
-  // make socket non-blocking
-  opt.option = PR_SockOpt_Nonblocking;
-  opt.value.non_blocking = PR_TRUE;
-  PR_SetSocketOption(fd, &opt);
-
-  // do some security checks on connection socket...
-  if (DoSecurityCheck(fd, addr.local.path) != PR_SUCCESS)
-    goto end;
-  
-  *result = fd;
-  return NS_OK;
-
-end:
-  if (fd)
-    PR_Close(fd);
-
-  return rv;
-}
-
-nsresult
-IPC_Connect(const char *daemonPath)
-{
-  // synchronous connect, spawn daemon if necessary.
-
-  PRFileDesc *fd;
-  nsresult rv = NS_ERROR_FAILURE;
-
-  if (gConnState)
-    return NS_ERROR_ALREADY_INITIALIZED;
-
-  //
-  // here's the connection algorithm:  try to connect to an existing daemon.
-  // if the connection fails, then spawn the daemon (wait for it to be ready),
-  // and then retry the connection.  it is critical that the socket used to
-  // connect to the daemon not be inherited (this causes problems on RH9 at
-  // least).
-  //
-
-  rv = TryConnect(&fd);
-  if (NS_FAILED(rv))
-  {
-    rv = IPC_SpawnDaemon(daemonPath);
-    if (NS_SUCCEEDED(rv))
-      rv = TryConnect(&fd);
-  }
-
-  if (NS_FAILED(rv))
-    goto end;
-
-  //
-  // ok, we have a connection to the daemon!
-  //
-
-  // build connection state object
-  gConnState = ConnCreate(fd);
-  if (!gConnState)
-  {
-    rv = NS_ERROR_OUT_OF_MEMORY;
-    goto end;
-  }
-  fd = NULL; // connection state now owns the socket
-
-  gConnThread = PR_CreateThread(PR_USER_THREAD,
-                                ConnThread,
-                                gConnState,
-                                PR_PRIORITY_NORMAL,
-                                PR_GLOBAL_THREAD,
-                                PR_JOINABLE_THREAD,
-                                0);
-  if (!gConnThread)
-  {
-    rv = NS_ERROR_OUT_OF_MEMORY;
-    goto end;
-  }
-
-#ifdef DEBUG
-  gMainThread = PR_GetCurrentThread();
-#endif
-  return NS_OK;
-
-end:
-  if (gConnState)
-  {
-    ConnDestroy(gConnState);
-    gConnState = NULL;
-  }
-  if (fd)
-    PR_Close(fd);
-  return rv;
-}
-
-nsresult
-IPC_Disconnect()
-{
-  // Must disconnect on same thread used to connect!
-  PR_ASSERT(gMainThread == PR_GetCurrentThread());
-
-  if (!gConnState || !gConnThread)
-    return NS_ERROR_NOT_INITIALIZED;
-
-  PR_Lock(gConnState->lock);
-  gConnState->shutdown = PR_TRUE;
-  PR_SetPollableEvent(gConnState->fds[POLL].fd);
-  PR_Unlock(gConnState->lock);
-
-  PR_JoinThread(gConnThread);
-
-  ConnDestroy(gConnState);
-
-  gConnState = NULL;
-  gConnThread = NULL;
-  return NS_OK;
-}
-
-nsresult
-IPC_SendMsg(ipcMessage *msg)
-{
-  if (!gConnState || !gConnThread)
-    return NS_ERROR_NOT_INITIALIZED;
-
-  PR_Lock(gConnState->lock);
-  gConnState->send_queue.Append(msg);
-  PR_SetPollableEvent(gConnState->fds[POLL].fd);
-  PR_Unlock(gConnState->lock);
-
-  return NS_OK;
-}
-
-nsresult
-IPC_DoCallback(ipcCallbackFunc func, void *arg)
-{
-  if (!gConnState || !gConnThread)
-    return NS_ERROR_NOT_INITIALIZED;
-  
-  ipcCallback *callback = new ipcCallback;
-  if (!callback)
-    return NS_ERROR_OUT_OF_MEMORY;
-  callback->func = func;
-  callback->arg = arg;
-
-  PR_Lock(gConnState->lock);
-  gConnState->callback_queue.Append(callback);
-  PR_SetPollableEvent(gConnState->fds[POLL].fd);
-  PR_Unlock(gConnState->lock);
-  return NS_OK;
-}
-
-//-----------------------------------------------------------------------------
-
-#ifdef TEST_STANDALONE
-
-void IPC_OnConnectionFault(nsresult rv)
-{
-  LOG(("IPC_OnConnectionFault [rv=%x]\n", rv));
-}
-
-void IPC_OnMessageAvailable(ipcMessage *msg)
-{
-  LOG(("IPC_OnMessageAvailable\n"));
-  delete msg;
-}
-
-int main()
-{
-  IPC_InitLog(">>>");
-  IPC_Connect("/builds/moz-trunk/seamonkey-debug-build/dist/bin/mozilla-ipcd");
-  IPC_Disconnect();
-  return 0;
-}
-
-#endif
deleted file mode 100644
--- a/ipc/ipcd/client/src/ipcConnectionWin.cpp
+++ /dev/null
@@ -1,332 +0,0 @@
-/* ***** 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 IPC.
- *
- * The Initial Developer of the Original Code is
- * Netscape Communications Corporation.
- * Portions created by the Initial Developer are Copyright (C) 2002
- * the Initial Developer. All Rights Reserved.
- *
- * Contributor(s):
- *   Darin Fisher <darin@meer.net>
- *
- * Alternatively, the contents of this file may be used under the terms of
- * either 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 <windows.h>
-
-#include "prprf.h"
-#include "prmon.h"
-#include "prthread.h"
-#include "plevent.h"
-
-#include "nsIServiceManager.h"
-#include "nsIEventQueue.h"
-#include "nsIEventQueueService.h"
-#include "nsAutoLock.h"
-
-#include "ipcConfig.h"
-#include "ipcLog.h"
-#include "ipcConnection.h"
-#include "ipcm.h"
-
-
-//-----------------------------------------------------------------------------
-// NOTE: this code does not need to link with anything but NSPR.  that is by
-//       design, so it can be easily reused in other projects that want to 
-//       talk with mozilla's IPC daemon, but don't want to depend on xpcom.
-//       we depend at most on some xpcom header files, but no xpcom runtime
-//       symbols are used.
-//-----------------------------------------------------------------------------
-
-
-//-----------------------------------------------------------------------------
-// windows message thread
-//-----------------------------------------------------------------------------
-
-#define IPC_WM_SENDMSG    (WM_USER + 0x1)
-#define IPC_WM_CALLBACK   (WM_USER + 0x2)
-#define IPC_WM_SHUTDOWN   (WM_USER + 0x3)
-
-static nsresult       ipcThreadStatus = NS_OK;
-static PRThread      *ipcThread = NULL;
-static PRMonitor     *ipcMonitor = NULL;
-static HWND           ipcDaemonHwnd = NULL;
-static HWND           ipcLocalHwnd = NULL;
-static PRBool         ipcShutdown = PR_FALSE; // not accessed on message thread!!
-
-//-----------------------------------------------------------------------------
-// window proc
-//-----------------------------------------------------------------------------
-
-static LRESULT CALLBACK
-ipcThreadWindowProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
-{
-    LOG(("got message [msg=%x wparam=%x lparam=%x]\n", uMsg, wParam, lParam));
-
-    if (uMsg == WM_COPYDATA) {
-        COPYDATASTRUCT *cd = (COPYDATASTRUCT *) lParam;
-        if (cd && cd->lpData) {
-            ipcMessage *msg = new ipcMessage();
-            PRUint32 bytesRead;
-            PRBool complete;
-            PRStatus rv = msg->ReadFrom((const char *) cd->lpData, cd->cbData,
-                                        &bytesRead, &complete);
-            if (rv == PR_SUCCESS && complete)
-                IPC_OnMessageAvailable(msg); // takes ownership of msg
-            else {
-                LOG(("  unable to deliver message [complete=%u]\n", complete));
-                delete msg;
-            }
-        }
-        return TRUE;
-    }
-
-    if (uMsg == IPC_WM_SENDMSG) {
-        ipcMessage *msg = (ipcMessage *) lParam;
-        if (msg) {
-            LOG(("  sending message...\n"));
-            COPYDATASTRUCT cd;
-            cd.dwData = GetCurrentProcessId();
-            cd.cbData = (DWORD) msg->MsgLen();
-            cd.lpData = (PVOID) msg->MsgBuf();
-            SendMessageA(ipcDaemonHwnd, WM_COPYDATA, (WPARAM) hWnd, (LPARAM) &cd);
-            LOG(("  done.\n"));
-            delete msg;
-        }
-        return 0;
-    }
-
-    if (uMsg == IPC_WM_CALLBACK) {
-        ipcCallbackFunc func = (ipcCallbackFunc) wParam;
-        void *arg = (void *) lParam;
-        (func)(arg);
-        return 0;
-    }
-
-    if (uMsg == IPC_WM_SHUTDOWN) {
-        IPC_OnConnectionEnd(NS_OK);
-        PostQuitMessage(0);
-        return 0;
-    }
-
-    return DefWindowProc(hWnd, uMsg, wParam, lParam);
-}
-
-//-----------------------------------------------------------------------------
-// ipc thread functions
-//-----------------------------------------------------------------------------
-
-static void
-ipcThreadFunc(void *arg)
-{
-    LOG(("entering message thread\n"));
-
-    DWORD pid = GetCurrentProcessId();
-
-    WNDCLASS wc;
-    memset(&wc, 0, sizeof(wc));
-    wc.lpfnWndProc = ipcThreadWindowProc;
-    wc.lpszClassName = IPC_CLIENT_WINDOW_CLASS;
-    RegisterClass(&wc);
-
-    char wName[sizeof(IPC_CLIENT_WINDOW_NAME_PREFIX) + 20];
-    PR_snprintf(wName, sizeof(wName), "%s%u", IPC_CLIENT_WINDOW_NAME_PREFIX, pid);
-
-    ipcLocalHwnd = CreateWindow(IPC_CLIENT_WINDOW_CLASS, wName,
-                                0, 0, 0, 10, 10, NULL, NULL, NULL, NULL);
-
-    {
-        nsAutoMonitor mon(ipcMonitor);
-        if (!ipcLocalHwnd)
-            ipcThreadStatus = NS_ERROR_FAILURE;
-        mon.Notify();
-    }
-
-    if (ipcLocalHwnd) {
-        MSG msg;
-        while (GetMessage(&msg, ipcLocalHwnd, 0, 0))
-            DispatchMessage(&msg);
-
-        ipcShutdown = PR_TRUE; // assuming atomic memory write
-
-        DestroyWindow(ipcLocalHwnd);
-        ipcLocalHwnd = NULL;
-    }
-
-    LOG(("exiting message thread\n"));
-    return;
-}
-
-static PRStatus
-ipcThreadInit()
-{
-    if (ipcThread)
-        return PR_FAILURE;
-
-    ipcShutdown = PR_FALSE;
-
-    ipcMonitor = PR_NewMonitor();
-    if (!ipcMonitor)
-        return PR_FAILURE;
-
-    // spawn message thread
-    ipcThread = PR_CreateThread(PR_USER_THREAD, ipcThreadFunc, NULL,
-                                PR_PRIORITY_NORMAL, PR_GLOBAL_THREAD,
-                                PR_JOINABLE_THREAD, 0);
-    if (!ipcThread) {
-        NS_WARNING("thread creation failed");
-        PR_DestroyMonitor(ipcMonitor);
-        ipcMonitor = NULL;
-        return PR_FAILURE;
-    }
-
-    // wait for hidden window to be created
-    {
-        nsAutoMonitor mon(ipcMonitor);
-        while (!ipcLocalHwnd && NS_SUCCEEDED(ipcThreadStatus))
-            mon.Wait();
-    }
-
-    if (NS_FAILED(ipcThreadStatus)) {
-        NS_WARNING("message thread failed");
-        return PR_FAILURE;
-    }
-
-    return PR_SUCCESS;
-}
-
-static PRStatus
-ipcThreadShutdown()
-{
-    if (PR_AtomicSet(&ipcShutdown, PR_TRUE) == PR_FALSE) {
-        LOG(("posting IPC_WM_SHUTDOWN message\n"));
-        PostMessage(ipcLocalHwnd, IPC_WM_SHUTDOWN, 0, 0);
-    }
-
-    LOG(("joining w/ message thread...\n"));
-    PR_JoinThread(ipcThread);
-    ipcThread = NULL;
-
-    //
-    // ok, now the message thread is dead
-    //
-
-    PR_DestroyMonitor(ipcMonitor);
-    ipcMonitor = NULL;
-
-    return PR_SUCCESS;
-}
-
-//-----------------------------------------------------------------------------
-// windows specific IPC connection impl
-//-----------------------------------------------------------------------------
-
-nsresult
-IPC_Disconnect()
-{
-    LOG(("IPC_Disconnect\n"));
-
-    //XXX mHaveConnection = PR_FALSE;
-    
-    if (!ipcDaemonHwnd)
-        return NS_ERROR_NOT_INITIALIZED;
-
-    if (ipcThread)
-        ipcThreadShutdown();
-
-    // clear our reference to the daemon's HWND.
-    ipcDaemonHwnd = NULL;
-    return NS_OK;
-}
-
-nsresult
-IPC_Connect(const char *daemonPath)
-{
-    LOG(("IPC_Connect\n"));
-
-    NS_ENSURE_TRUE(ipcDaemonHwnd == NULL, NS_ERROR_ALREADY_INITIALIZED);
-    nsresult rv;
-
-    ipcDaemonHwnd = FindWindow(IPC_WINDOW_CLASS, IPC_WINDOW_NAME);
-    if (!ipcDaemonHwnd) {
-        LOG(("  daemon does not appear to be running\n"));
-        //
-        // daemon does not exist; spawn daemon...
-        //
-        rv = IPC_SpawnDaemon(daemonPath);
-        if (NS_FAILED(rv))
-            return rv;
-
-        ipcDaemonHwnd = FindWindow(IPC_WINDOW_CLASS, IPC_WINDOW_NAME);
-        if (!ipcDaemonHwnd)
-            return NS_ERROR_FAILURE;
-    }
-
-    // 
-    // delay creation of the message thread until we know the daemon exists.
-    //
-    if (!ipcThread && ipcThreadInit() != PR_SUCCESS) {
-        ipcDaemonHwnd = NULL;
-        return NS_ERROR_FAILURE;
-    }
-
-    return NS_OK;
-}
-
-nsresult
-IPC_SendMsg(ipcMessage *msg)
-{
-    LOG(("IPC_SendMsg\n"));
-
-    if (ipcShutdown) {
-        LOG(("unable to send message b/c message thread is shutdown\n"));
-        goto loser;
-    }
-    if (!PostMessage(ipcLocalHwnd, IPC_WM_SENDMSG, 0, (LPARAM) msg)) {
-        LOG(("  PostMessage failed w/ error = %u\n", GetLastError()));
-        goto loser;
-    }
-    return NS_OK;
-loser:
-    delete msg;
-    return NS_ERROR_FAILURE;
-}
-
-nsresult
-IPC_DoCallback(ipcCallbackFunc func, void *arg)
-{
-    LOG(("IPC_DoCallback\n"));
-
-    if (ipcShutdown) {
-        LOG(("unable to send message b/c message thread is shutdown\n"));
-        return NS_ERROR_FAILURE;
-    }
-    if (!PostMessage(ipcLocalHwnd, IPC_WM_CALLBACK, (WPARAM) func, (LPARAM) arg)) {
-        LOG(("  PostMessage failed w/ error = %u\n", GetLastError()));
-        return NS_ERROR_FAILURE;
-    }
-    return NS_OK;
-}
deleted file mode 100644
--- a/ipc/ipcd/client/src/ipcModuleFactory.cpp
+++ /dev/null
@@ -1,196 +0,0 @@
-/* ***** 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 IPC.
- *
- * The Initial Developer of the Original Code is
- * Netscape Communications Corporation.
- * Portions created by the Initial Developer are Copyright (C) 2002
- * the Initial Developer. All Rights Reserved.
- *
- * Contributor(s):
- *   Darin Fisher <darin@netscape.com>
- *
- * Alternatively, the contents of this file may be used under the terms of
- * either 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 "nsIServiceManager.h"
-#include "nsIGenericFactory.h"
-#include "nsICategoryManager.h"
-#include "ipcdclient.h"
-#include "ipcService.h"
-#include "ipcConfig.h"
-#include "ipcCID.h"
-
-//-----------------------------------------------------------------------------
-// Define the contructor function for the objects
-//
-// NOTE: This creates an instance of objects by using the default constructor
-//-----------------------------------------------------------------------------
-NS_GENERIC_FACTORY_CONSTRUCTOR(ipcService)
-
-// enable this code to make the IPC service auto-start.
-#if 0
-NS_METHOD
-ipcServiceRegisterProc(nsIComponentManager *aCompMgr,
-                       nsIFile *aPath,
-                       const char *registryLocation,
-                       const char *componentType,
-                       const nsModuleComponentInfo *info)
-{
-    //
-    // add ipcService to the XPCOM startup category
-    //
-    nsCOMPtr<nsICategoryManager> catman(do_GetService(NS_CATEGORYMANAGER_CONTRACTID));
-    if (catman) {
-        nsXPIDLCString prevEntry;
-        catman->AddCategoryEntry(NS_XPCOM_STARTUP_OBSERVER_ID, "ipcService",
-                                 IPC_SERVICE_CONTRACTID, PR_TRUE, PR_TRUE,
-                                 getter_Copies(prevEntry));
-    }
-    return NS_OK;
-}
-
-NS_METHOD
-ipcServiceUnregisterProc(nsIComponentManager *aCompMgr,
-                         nsIFile *aPath,
-                         const char *registryLocation,
-                         const nsModuleComponentInfo *info)
-{
-    nsCOMPtr<nsICategoryManager> catman(do_GetService(NS_CATEGORYMANAGER_CONTRACTID));
-    if (catman)
-        catman->DeleteCategoryEntry(NS_XPCOM_STARTUP_OBSERVER_ID, 
-                                    IPC_SERVICE_CONTRACTID, PR_TRUE);
-    return NS_OK;
-}
-#endif
-
-//-----------------------------------------------------------------------------
-// extensions
-
-#include "ipcLockService.h"
-#include "ipcLockCID.h"
-NS_GENERIC_FACTORY_CONSTRUCTOR_INIT(ipcLockService, Init)
-
-#include "tmTransactionService.h"
-NS_GENERIC_FACTORY_CONSTRUCTOR(tmTransactionService)
-
-#ifdef BUILD_DCONNECT
-
-#include "ipcDConnectService.h"
-NS_GENERIC_FACTORY_CONSTRUCTOR_INIT(ipcDConnectService, Init)
-
-// enable this code to make the IPC DCONNECT service auto-start.
-NS_METHOD
-ipcDConnectServiceRegisterProc(nsIComponentManager *aCompMgr,
-                               nsIFile *aPath,
-                               const char *registryLocation,
-                               const char *componentType,
-                               const nsModuleComponentInfo *info)
-{
-    //
-    // add ipcService to the XPCOM startup category
-    //
-    nsCOMPtr<nsICategoryManager> catman(do_GetService(NS_CATEGORYMANAGER_CONTRACTID));
-    if (catman) {
-        nsXPIDLCString prevEntry;
-        catman->AddCategoryEntry(NS_XPCOM_STARTUP_OBSERVER_ID, "ipcDConnectService",
-                                 IPC_DCONNECTSERVICE_CONTRACTID, PR_TRUE, PR_TRUE,
-                                 getter_Copies(prevEntry));
-    }
-    return NS_OK;
-}
-
-NS_METHOD
-ipcDConnectServiceUnregisterProc(nsIComponentManager *aCompMgr,
-                                 nsIFile *aPath,
-                                 const char *registryLocation,
-                                 const nsModuleComponentInfo *info)
-{
-    nsCOMPtr<nsICategoryManager> catman(do_GetService(NS_CATEGORYMANAGER_CONTRACTID));
-    if (catman)
-        catman->DeleteCategoryEntry(NS_XPCOM_STARTUP_OBSERVER_ID, 
-                                    IPC_DCONNECTSERVICE_CONTRACTID, PR_TRUE);
-    return NS_OK;
-}
-
-#endif // BUILD_DCONNECT
-
-//-----------------------------------------------------------------------------
-// Define a table of CIDs implemented by this module along with other
-// information like the function to create an instance, contractid, and
-// class name.
-//-----------------------------------------------------------------------------
-static const nsModuleComponentInfo components[] = {
-  { IPC_SERVICE_CLASSNAME,
-    IPC_SERVICE_CID,
-    IPC_SERVICE_CONTRACTID,
-    ipcServiceConstructor },
-    /*
-    ipcServiceRegisterProc,
-    ipcServiceUnregisterProc },
-    */
-  //
-  // extensions go here:
-  //
-  { IPC_LOCKSERVICE_CLASSNAME,
-    IPC_LOCKSERVICE_CID,
-    IPC_LOCKSERVICE_CONTRACTID,
-    ipcLockServiceConstructor },
-  { IPC_TRANSACTIONSERVICE_CLASSNAME,
-    IPC_TRANSACTIONSERVICE_CID,
-    IPC_TRANSACTIONSERVICE_CONTRACTID,
-    tmTransactionServiceConstructor },
-
-#ifdef BUILD_DCONNECT
-  { IPC_DCONNECTSERVICE_CLASSNAME,
-    IPC_DCONNECTSERVICE_CID,
-    IPC_DCONNECTSERVICE_CONTRACTID,
-    ipcDConnectServiceConstructor,
-    ipcDConnectServiceRegisterProc,
-    ipcDConnectServiceUnregisterProc },
-#endif
-};
-
-//-----------------------------------------------------------------------------
-
-static nsresult
-ipcdclient_init(nsIModule *module)
-{
-  return IPC_Init();
-}
-
-static void
-ipcdclient_shutdown(nsIModule *module)
-{
-  IPC_Shutdown();
-}
-
-//-----------------------------------------------------------------------------
-// Implement the NSGetModule() exported function for your module
-// and the entire implementation of the module object.
-//-----------------------------------------------------------------------------
-NS_IMPL_NSGETMODULE_WITH_CTOR_DTOR(ipcdclient, components,
-                                   ipcdclient_init,
-                                   ipcdclient_shutdown)
deleted file mode 100644
--- a/ipc/ipcd/client/src/ipcService.cpp
+++ /dev/null
@@ -1,120 +0,0 @@
-/* vim:set ts=4 sw=4 et cindent: */
-/* ***** 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 IPC.
- *
- * The Initial Developer of the Original Code is IBM Corporation.
- * Portions created by the Initial Developer are Copyright (C) 2004
- * the Initial Developer. All Rights Reserved.
- *
- * Contributor(s):
- *   Darin Fisher <darin@meer.net>
- *
- * Alternatively, the contents of this file may be used under the terms of
- * either 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 "ipcService.h"
-
-// The ipcService implementation is nothing more than a thin XPCOM wrapper
-// around the ipcdclient.h API.
-
-NS_IMPL_THREADSAFE_ISUPPORTS1(ipcService, ipcIService)
-
-NS_IMETHODIMP
-ipcService::GetID(PRUint32 *aID)
-{
-    return IPC_GetID(aID);
-}
-
-NS_IMETHODIMP
-ipcService::AddName(const char *aName)
-{
-    return IPC_AddName(aName);
-}
-
-NS_IMETHODIMP
-ipcService::RemoveName(const char *aName)
-{
-    return IPC_RemoveName(aName);
-}
-
-NS_IMETHODIMP
-ipcService::AddClientObserver(ipcIClientObserver *aObserver)
-{
-    return IPC_AddClientObserver(aObserver);
-}
-
-NS_IMETHODIMP
-ipcService::RemoveClientObserver(ipcIClientObserver *aObserver)
-{
-    return IPC_RemoveClientObserver(aObserver);
-}
-
-NS_IMETHODIMP
-ipcService::ResolveClientName(const char *aName, PRUint32 *aID)
-{
-    return IPC_ResolveClientName(aName, aID);
-}
-
-NS_IMETHODIMP
-ipcService::ClientExists(PRUint32 aClientID, PRBool *aResult)
-{
-    return IPC_ClientExists(aClientID, aResult);
-}
-
-NS_IMETHODIMP
-ipcService::DefineTarget(const nsID &aTarget, ipcIMessageObserver *aObserver,
-                         PRBool aOnCurrentThread)
-{
-    return IPC_DefineTarget(aTarget, aObserver, aOnCurrentThread);
-}
-
-NS_IMETHODIMP
-ipcService::SendMessage(PRUint32 aReceiverID, const nsID &aTarget,
-                        const PRUint8 *aData, PRUint32 aDataLen)
-{
-    return IPC_SendMessage(aReceiverID, aTarget, aData, aDataLen);
-}
-
-NS_IMETHODIMP
-ipcService::WaitMessage(PRUint32 aSenderID, const nsID &aTarget,
-                        ipcIMessageObserver *aObserver,
-                        PRUint32 aTimeout)
-{
-    return IPC_WaitMessage(aSenderID, aTarget, aObserver,
-                           PR_MillisecondsToInterval(aTimeout));
-}
-
-NS_IMETHODIMP
-ipcService::DisableMessageObserver(const nsID &aTarget)
-{
-    return IPC_DisableMessageObserver(aTarget);
-}
-
-NS_IMETHODIMP
-ipcService::EnableMessageObserver(const nsID &aTarget)
-{
-    return IPC_EnableMessageObserver(aTarget);
-}
deleted file mode 100644
--- a/ipc/ipcd/client/src/ipcService.h
+++ /dev/null
@@ -1,51 +0,0 @@
-/* ***** 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 IPC.
- *
- * The Initial Developer of the Original Code is
- * Netscape Communications Corporation.
- * Portions created by the Initial Developer are Copyright (C) 2002
- * the Initial Developer. All Rights Reserved.
- *
- * Contributor(s):
- *   Darin Fisher <darin@netscape.com>
- *
- * Alternatively, the contents of this file may be used under the terms of
- * either 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 ipcService_h__
-#define ipcService_h__
-
-#include "ipcIService.h"
-#include "ipcdclient.h"
-
-class ipcService : public ipcIService
-{
-public:
-    NS_DECL_ISUPPORTS
-    NS_DECL_IPCISERVICE
-};
-
-#endif // !defined( ipcService_h__ )
deleted file mode 100644
--- a/ipc/ipcd/client/src/ipcdclient.cpp
+++ /dev/null
@@ -1,1097 +0,0 @@
-/* vim:set ts=2 sw=2 et cindent: */
-/* ***** 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 IPC.
- *
- * The Initial Developer of the Original Code is IBM Corporation.
- * Portions created by the Initial Developer are Copyright (C) 2004
- * the Initial Developer. All Rights Reserved.
- *
- * Contributor(s):
- *   Darin Fisher <darin@meer.net>
- *
- * Alternatively, the contents of this file may be used under the terms of
- * either 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 "ipcdclient.h"
-#include "ipcConnection.h"
-#include "ipcConfig.h"
-#include "ipcMessageQ.h"
-#include "ipcMessageUtils.h"
-#include "ipcLog.h"
-#include "ipcm.h"
-
-#include "nsIFile.h"
-#include "nsThreadUtils.h"
-#include "nsDirectoryServiceUtils.h"
-#include "nsDirectoryServiceDefs.h"
-#include "nsCOMPtr.h"
-#include "nsHashKeys.h"
-#include "nsRefPtrHashtable.h"
-#include "nsAutoLock.h"
-#include "nsProxyRelease.h"
-#include "nsCOMArray.h"
-
-#include "prio.h"
-#include "prproces.h"
-#include "pratom.h"
-
-/* ------------------------------------------------------------------------- */
-
-#define IPC_REQUEST_TIMEOUT PR_SecondsToInterval(30)
-
-/* ------------------------------------------------------------------------- */
-
-class ipcTargetData
-{
-public:
-  static NS_HIDDEN_(ipcTargetData*) Create();
-
-  // threadsafe addref/release
-  NS_HIDDEN_(nsrefcnt) AddRef()  { return PR_AtomicIncrement(&refcnt); }
-  NS_HIDDEN_(nsrefcnt) Release() { PRInt32 r = PR_AtomicDecrement(&refcnt); if (r == 0) delete this; return r; }
-
-  NS_HIDDEN_(void) SetObserver(ipcIMessageObserver *aObserver, PRBool aOnCurrentThread);
-
-  // protects access to the members of this class
-  PRMonitor *monitor;
-
-  // this may be null
-  nsCOMPtr<ipcIMessageObserver> observer;
-
-  // the message observer is called on this thread
-  nsCOMPtr<nsIThread> thread;
-  
-  // incoming messages are added to this list
-  ipcMessageQ pendingQ;
-
-  // non-zero if the observer has been disabled (this means that new messages
-  // should not be dispatched to the observer until the observer is re-enabled
-  // via IPC_EnableMessageObserver).
-  PRInt32 observerDisabled;
-
-private:
-
-  ipcTargetData()
-    : monitor(PR_NewMonitor())
-    , observerDisabled(0)
-    , refcnt(0)
-    {}
-
-  ~ipcTargetData()
-  {
-    if (monitor)
-      PR_DestroyMonitor(monitor);
-  }
-
-  PRInt32 refcnt;
-};
-
-ipcTargetData *
-ipcTargetData::Create()
-{
-  ipcTargetData *td = new ipcTargetData;
-  if (!td)
-    return NULL;
-
-  if (!td->monitor)
-  {
-    delete td;
-    return NULL;
-  }
-  return td;
-}
-
-void
-ipcTargetData::SetObserver(ipcIMessageObserver *aObserver, PRBool aOnCurrentThread)
-{
-  observer = aObserver;
-
-  if (aOnCurrentThread)
-    NS_GetCurrentThread(getter_AddRefs(thread));
-  else
-    thread = nsnull;
-}
-
-/* ------------------------------------------------------------------------- */
-
-typedef nsRefPtrHashtable<nsIDHashKey, ipcTargetData> ipcTargetMap; 
-
-class ipcClientState
-{
-public:
-  static NS_HIDDEN_(ipcClientState *) Create();
-
-  ~ipcClientState()
-  {
-    if (monitor)
-      PR_DestroyMonitor(monitor);
-  }
-
-  //
-  // the monitor protects the targetMap and the connected flag.  
-  //
-  // NOTE: we use a PRMonitor for this instead of a PRLock because we need
-  //       the lock to be re-entrant.  since we don't ever need to wait on
-  //       this monitor, it might be worth it to implement a re-entrant
-  //       wrapper for PRLock.
-  //
-  PRMonitor    *monitor;
-  ipcTargetMap  targetMap;
-  PRBool        connected;
-
-  // our process's client id
-  PRUint32      selfID; 
-
-  nsCOMArray<ipcIClientObserver> clientObservers;
-
-private:
-
-  ipcClientState()
-    : monitor(PR_NewMonitor())
-    , connected(PR_FALSE)
-    , selfID(0)
-  {}
-};
-
-ipcClientState *
-ipcClientState::Create()
-{
-  ipcClientState *cs = new ipcClientState;
-  if (!cs)
-    return NULL;
-
-  if (!cs->monitor || !cs->targetMap.Init())
-  {
-    delete cs;
-    return NULL;
-  }
-
-  return cs;
-}
-
-/* ------------------------------------------------------------------------- */
-
-static ipcClientState *gClientState;
-
-static PRBool
-GetTarget(const nsID &aTarget, ipcTargetData **td)
-{
-  nsAutoMonitor mon(gClientState->monitor);
-  return gClientState->targetMap.Get(nsIDHashKey(&aTarget).GetKey(), td);
-}
-
-static PRBool
-PutTarget(const nsID &aTarget, ipcTargetData *td)
-{
-  nsAutoMonitor mon(gClientState->monitor);
-  return gClientState->targetMap.Put(nsIDHashKey(&aTarget).GetKey(), td);
-}
-
-static void
-DelTarget(const nsID &aTarget)
-{
-  nsAutoMonitor mon(gClientState->monitor);
-  gClientState->targetMap.Remove(nsIDHashKey(&aTarget).GetKey());
-}
-
-/* ------------------------------------------------------------------------- */
-
-static nsresult
-GetDaemonPath(nsCString &dpath)
-{
-  nsCOMPtr<nsIFile> file;
-
-  nsresult rv = NS_GetSpecialDirectory(NS_XPCOM_CURRENT_PROCESS_DIR,
-                                       getter_AddRefs(file));
-  if (NS_SUCCEEDED(rv))
-  {
-    rv = file->AppendNative(NS_LITERAL_CSTRING(IPC_DAEMON_APP_NAME));
-    if (NS_SUCCEEDED(rv))
-      rv = file->GetNativePath(dpath);
-  }
-
-  return rv;
-}
-
-/* ------------------------------------------------------------------------- */
-
-static void
-ProcessPendingQ(const nsID &aTarget)
-{
-  ipcMessageQ tempQ;
-
-  nsRefPtr<ipcTargetData> td;
-  if (GetTarget(aTarget, getter_AddRefs(td)))
-  {
-    nsAutoMonitor mon(td->monitor);
-
-    // if the observer for this target has been temporarily disabled, then
-    // we must not processing any pending messages at this time.
-
-    if (!td->observerDisabled)
-      td->pendingQ.MoveTo(tempQ);
-  }
-
-  // process pending queue outside monitor
-  while (!tempQ.IsEmpty())
-  {
-    ipcMessage *msg = tempQ.First();
-
-    if (td->observer)
-      td->observer->OnMessageAvailable(msg->mMetaData,
-                                       msg->Target(),
-                                       (const PRUint8 *) msg->Data(),
-                                       msg->DataLen());
-    else
-    {
-      // the IPCM target does not have an observer, and therefore any IPCM
-      // messages that make it here will simply be dropped.
-      NS_ASSERTION(aTarget.Equals(IPCM_TARGET), "unexpected target");
-      LOG(("dropping IPCM message: type=%x\n", IPCM_GetType(msg)));
-    }
-    tempQ.DeleteFirst();
-  }
-}
-
-/* ------------------------------------------------------------------------- */
-
-// WaitTarget enables support for multiple threads blocking on the same
-// message target.  the selector is called while inside the target's monitor.
-
-typedef PRBool (* ipcMessageSelector)(
-  void *arg,
-  ipcTargetData *td,
-  const ipcMessage *msg
-);
-
-// selects any
-static PRBool
-DefaultSelector(void *arg, ipcTargetData *td, const ipcMessage *msg)
-{
-  return PR_TRUE;
-}
-
-static nsresult
-WaitTarget(const nsID           &aTarget,
-           PRIntervalTime        aTimeout,
-           ipcMessage          **aMsg,
-           ipcMessageSelector    aSelector = nsnull,
-           void                 *aArg = nsnull)
-{
-  *aMsg = nsnull;
-
-  if (!aSelector)
-    aSelector = DefaultSelector;
-
-  nsRefPtr<ipcTargetData> td;
-  if (!GetTarget(aTarget, getter_AddRefs(td)))
-    return NS_ERROR_INVALID_ARG; // bad aTarget
-
-  PRIntervalTime timeStart = PR_IntervalNow();
-  PRIntervalTime timeEnd;
-  if (aTimeout == PR_INTERVAL_NO_TIMEOUT)
-    timeEnd = aTimeout;
-  else if (aTimeout == PR_INTERVAL_NO_WAIT)
-    timeEnd = timeStart;
-  else
-  {
-    timeEnd = timeStart + aTimeout;
-
-    // if overflowed, then set to max value
-    if (timeEnd < timeStart)
-      timeEnd = PR_INTERVAL_NO_TIMEOUT;
-  }
-
-  ipcMessage *lastChecked = nsnull, *beforeLastChecked = nsnull;
-  nsresult rv = NS_ERROR_FAILURE;
-
-  nsAutoMonitor mon(td->monitor);
-
-  while (gClientState->connected)
-  {
-    NS_ASSERTION(!lastChecked, "oops");
-
-    //
-    // NOTE:
-    //
-    // we must start at the top of the pending queue, possibly revisiting
-    // messages that our selector has already rejected.  this is necessary
-    // because the queue may have been modified while we were waiting on
-    // the monitor.  the impact of this on performance remains to be seen.
-    //
-    // one cheap solution is to keep a counter that is incremented each
-    // time a message is removed from the pending queue.  that way we can
-    // avoid revisiting all messages sometimes.
-    //
-
-    lastChecked = td->pendingQ.First();
-    beforeLastChecked = nsnull;
-
-    // loop over pending queue until we find a message that our selector likes.
-    while (lastChecked)
-    {
-      if ((aSelector)(aArg, td, lastChecked))
-      {
-        // remove from pending queue
-        if (beforeLastChecked)
-          td->pendingQ.RemoveAfter(beforeLastChecked);
-        else
-          td->pendingQ.RemoveFirst();
-        lastChecked->mNext = nsnull;
-
-        *aMsg = lastChecked;
-        break;
-      }
-
-      beforeLastChecked = lastChecked;
-      lastChecked = lastChecked->mNext;
-    }
-      
-    if (*aMsg)
-    {
-      rv = NS_OK;
-      break;
-    }
-
-    // make sure we are still connected before waiting...
-    if (!gClientState->connected)
-    {
-      rv = NS_ERROR_ABORT;
-      break;
-    }
-
-    PRIntervalTime t = PR_IntervalNow();
-    if (t > timeEnd) // check if timeout has expired
-    {
-      rv = IPC_ERROR_WOULD_BLOCK;
-      break;
-    }
-    mon.Wait(timeEnd - t);
-
-    LOG(("woke up from sleep [pendingQempty=%d connected=%d]\n",
-          td->pendingQ.IsEmpty(), gClientState->connected));
-  }
-
-  return rv;
-}
-
-/* ------------------------------------------------------------------------- */
-
-class ipcEvent_ClientState : public nsRunnable
-{
-public:
-  ipcEvent_ClientState(PRUint32 aClientID, PRUint32 aClientState)
-    : mClientID(aClientID)
-    , mClientState(aClientState)
-  {
-  }
-
-  NS_IMETHOD Run()
-  {
-    // maybe we've been shutdown!
-    if (!gClientState)
-      return nsnull;
-
-    for (PRInt32 i=0; i<gClientState->clientObservers.Count(); ++i)
-      gClientState->clientObservers[i]->OnClientStateChange(mClientID,
-                                                            mClientState);
-    return nsnull;
-  }
-
-private:
-  PRUint32 mClientID;
-  PRUint32 mClientState;
-};
-
-/* ------------------------------------------------------------------------- */
-
-class ipcEvent_ProcessPendingQ : public nsRunnable
-{
-public:
-  ipcEvent_ProcessPendingQ(const nsID &aTarget)
-    : mTarget(aTarget)
-  {
-  }
-
-  NS_IMETHOD Run()
-  {
-    ProcessPendingQ(mTarget);
-    return NS_OK;
-  }
-
-private:
-  const nsID mTarget;
-};
-
-static void
-RunEvent(void *arg)
-{
-  nsIRunnable *ev = static_cast<nsIRunnable *>(arg);
-  ev->Run();
-  NS_RELEASE(ev);
-}
-
-static void
-CallProcessPendingQ(const nsID &target, ipcTargetData *td)
-{
-  // we assume that we are inside td's monitor 
-
-  nsIRunnable *ev = new ipcEvent_ProcessPendingQ(target);
-  if (!ev)
-    return;
-  NS_ADDREF(ev);
-
-  nsresult rv;
-
-  if (td->thread)
-  {
-    rv = td->thread->Dispatch(ev, NS_DISPATCH_NORMAL);
-    NS_RELEASE(ev);
-  }
-  else 
-  {
-    rv = IPC_DoCallback(RunEvent, ev);
-  }
-
-  NS_WARN_IF_FALSE(NS_SUCCEEDED(rv), "failed to process pending queue");
-}
-
-/* ------------------------------------------------------------------------- */
-
-static void
-DisableMessageObserver(const nsID &aTarget)
-{
-  nsRefPtr<ipcTargetData> td;
-  if (GetTarget(aTarget, getter_AddRefs(td)))
-  {
-    nsAutoMonitor mon(td->monitor);
-    ++td->observerDisabled;
-  }
-}
-
-static void
-EnableMessageObserver(const nsID &aTarget)
-{
-  nsRefPtr<ipcTargetData> td;
-  if (GetTarget(aTarget, getter_AddRefs(td)))
-  {
-    nsAutoMonitor mon(td->monitor);
-    if (td->observerDisabled > 0 && --td->observerDisabled == 0)
-      if (!td->pendingQ.IsEmpty())
-        CallProcessPendingQ(aTarget, td);
-  }
-}
-
-/* ------------------------------------------------------------------------- */
-
-// selects the next IPCM message with matching request index
-static PRBool
-WaitIPCMResponseSelector(void *arg, ipcTargetData *td, const ipcMessage *msg)
-{
-  PRUint32 requestIndex = *(PRUint32 *) arg;
-  return IPCM_GetRequestIndex(msg) == requestIndex;
-}
-
-// wait for an IPCM response message.  if responseMsg is null, then it is
-// assumed that the caller does not care to get a reference to the 
-// response itself.  if the response is an IPCM_MSG_ACK_RESULT, then the
-// status code is mapped to a nsresult and returned by this function.
-static nsresult
-WaitIPCMResponse(PRUint32 requestIndex, ipcMessage **responseMsg = nsnull)
-{
-  ipcMessage *msg;
-
-  nsresult rv = WaitTarget(IPCM_TARGET, IPC_REQUEST_TIMEOUT, &msg,
-                           WaitIPCMResponseSelector, &requestIndex);
-  if (NS_FAILED(rv))
-    return rv;
-
-  if (IPCM_GetType(msg) == IPCM_MSG_ACK_RESULT)
-  {
-    ipcMessageCast<ipcmMessageResult> result(msg);
-    if (result->Status() < 0)
-      rv = NS_ERROR_FAILURE; // XXX nsresult_from_ipcm_result()
-    else
-      rv = NS_OK;
-  }
-
-  if (responseMsg)
-    *responseMsg = msg;
-  else
-    delete msg;
-
-  return rv;
-}
-
-// make an IPCM request and wait for a response.
-static nsresult
-MakeIPCMRequest(ipcMessage *msg, ipcMessage **responseMsg = nsnull)
-{
-  if (!msg)
-    return NS_ERROR_OUT_OF_MEMORY;
-
-  PRUint32 requestIndex = IPCM_GetRequestIndex(msg);
-
-  // suppress 'ProcessPendingQ' for IPCM messages until we receive the
-  // response to this IPCM request.  if we did not do this then there
-  // would be a race condition leading to the possible removal of our
-  // response from the pendingQ between sending the request and waiting
-  // for the response.
-  DisableMessageObserver(IPCM_TARGET);
-
-  nsresult rv = IPC_SendMsg(msg);
-  if (NS_SUCCEEDED(rv))
-    rv = WaitIPCMResponse(requestIndex, responseMsg);
-
-  EnableMessageObserver(IPCM_TARGET);
-  return rv;
-}
-
-/* ------------------------------------------------------------------------- */
-
-static void
-RemoveTarget(const nsID &aTarget, PRBool aNotifyDaemon)
-{
-  DelTarget(aTarget);
-
-  if (aNotifyDaemon)
-  {
-    nsresult rv = MakeIPCMRequest(new ipcmMessageClientDelTarget(aTarget));
-    if (NS_FAILED(rv))
-      LOG(("failed to delete target: rv=%x\n", rv));
-  }
-}
-
-static nsresult
-DefineTarget(const nsID           &aTarget,
-             ipcIMessageObserver  *aObserver,
-             PRBool                aOnCurrentThread,
-             PRBool                aNotifyDaemon,
-             ipcTargetData       **aResult)
-{
-  nsresult rv;
-
-  nsRefPtr<ipcTargetData> td( ipcTargetData::Create() );
-  if (!td)
-    return NS_ERROR_OUT_OF_MEMORY;
-  td->SetObserver(aObserver, aOnCurrentThread);
-
-  if (!PutTarget(aTarget, td))
-    return NS_ERROR_OUT_OF_MEMORY;
-
-  if (aNotifyDaemon)
-  {
-    rv = MakeIPCMRequest(new ipcmMessageClientAddTarget(aTarget));
-    if (NS_FAILED(rv))
-    {
-      LOG(("failed to add target: rv=%x\n", rv));
-      RemoveTarget(aTarget, PR_FALSE);
-      return rv;
-    }
-  }
-
-  if (aResult)
-    NS_ADDREF(*aResult = td);
-  return NS_OK;
-}
-
-/* ------------------------------------------------------------------------- */
-
-static nsresult
-TryConnect()
-{
-  nsCAutoString dpath;
-  nsresult rv = GetDaemonPath(dpath);
-  if (NS_FAILED(rv))
-    return rv;
-  
-  rv = IPC_Connect(dpath.get());
-  if (NS_FAILED(rv))
-    return rv;
-
-  gClientState->connected = PR_TRUE;
-
-  rv = DefineTarget(IPCM_TARGET, nsnull, PR_FALSE, PR_FALSE, nsnull);
-  if (NS_FAILED(rv))
-    return rv;
-
-  ipcMessage *msg;
-
-  // send CLIENT_HELLO and wait for CLIENT_ID response...
-  rv = MakeIPCMRequest(new ipcmMessageClientHello(), &msg);
-  if (NS_FAILED(rv))
-    return rv;
-
-  if (IPCM_GetType(msg) == IPCM_MSG_ACK_CLIENT_ID)
-    gClientState->selfID = ipcMessageCast<ipcmMessageClientID>(msg)->ClientID();
-  else
-  {
-    LOG(("unexpected response from CLIENT_HELLO message: type=%x!\n",
-        IPCM_GetType(msg)));
-    rv = NS_ERROR_UNEXPECTED;
-  }
-
-  delete msg;
-  return rv;
-}
-
-nsresult
-IPC_Init()
-{
-  NS_ENSURE_TRUE(!gClientState, NS_ERROR_ALREADY_INITIALIZED);
-
-  IPC_InitLog(">>>");
-
-  gClientState = ipcClientState::Create();
-  if (!gClientState)
-    return NS_ERROR_OUT_OF_MEMORY;
-
-  nsresult rv = TryConnect();
-  if (NS_FAILED(rv))
-    IPC_Shutdown();
-
-  return rv;
-}
-
-nsresult
-IPC_Shutdown()
-{
-  NS_ENSURE_TRUE(gClientState, NS_ERROR_NOT_INITIALIZED);
-
-  if (gClientState->connected)
-    IPC_Disconnect();
-
-  delete gClientState;
-  gClientState = nsnull;
-
-  return NS_OK;
-}
-
-/* ------------------------------------------------------------------------- */
-
-nsresult
-IPC_DefineTarget(const nsID          &aTarget,
-                 ipcIMessageObserver *aObserver,
-                 PRBool               aOnCurrentThread)
-{
-  NS_ENSURE_TRUE(gClientState, NS_ERROR_NOT_INITIALIZED);
-
-  // do not permit the re-definition of the IPCM protocol's target.
-  if (aTarget.Equals(IPCM_TARGET))
-    return NS_ERROR_INVALID_ARG;
-
-  nsresult rv;
-
-  nsRefPtr<ipcTargetData> td;
-  if (GetTarget(aTarget, getter_AddRefs(td)))
-  {
-    // clear out observer before removing target since we want to ensure that
-    // the observer is released on the main thread.
-    {
-      nsAutoMonitor mon(td->monitor);
-      td->SetObserver(aObserver, aOnCurrentThread);
-    }
-
-    // remove target outside of td's monitor to avoid holding the monitor
-    // while entering the client state's monitor.
-    if (!aObserver)
-      RemoveTarget(aTarget, PR_TRUE);
-
-    rv = NS_OK;
-  }
-  else
-  {
-    if (aObserver)
-      rv = DefineTarget(aTarget, aObserver, aOnCurrentThread, PR_TRUE, nsnull);
-    else
-      rv = NS_ERROR_INVALID_ARG; // unknown target
-  }
-
-  return rv;
-}
-
-nsresult
-IPC_DisableMessageObserver(const nsID &aTarget)
-{
-  NS_ENSURE_TRUE(gClientState, NS_ERROR_NOT_INITIALIZED);
-
-  // do not permit modifications to the IPCM protocol's target.
-  if (aTarget.Equals(IPCM_TARGET))
-    return NS_ERROR_INVALID_ARG;
-
-  DisableMessageObserver(aTarget);
-  return NS_OK;
-}
-
-nsresult
-IPC_EnableMessageObserver(const nsID &aTarget)
-{
-  NS_ENSURE_TRUE(gClientState, NS_ERROR_NOT_INITIALIZED);
-
-  // do not permit modifications to the IPCM protocol's target.
-  if (aTarget.Equals(IPCM_TARGET))
-    return NS_ERROR_INVALID_ARG;
-
-  EnableMessageObserver(aTarget);
-  return NS_OK;
-}
-
-nsresult
-IPC_SendMessage(PRUint32       aReceiverID,
-                const nsID    &aTarget,
-                const PRUint8 *aData,
-                PRUint32       aDataLen)
-{
-  NS_ENSURE_TRUE(gClientState, NS_ERROR_NOT_INITIALIZED);
-
-  // do not permit sending IPCM messages
-  if (aTarget.Equals(IPCM_TARGET))
-    return NS_ERROR_INVALID_ARG;
-
-  nsresult rv;
-  if (aReceiverID == 0)
-  {
-    ipcMessage *msg = new ipcMessage(aTarget, (const char *) aData, aDataLen);
-    if (!msg)
-      return NS_ERROR_OUT_OF_MEMORY;
-
-    rv = IPC_SendMsg(msg);
-  }
-  else
-    rv = MakeIPCMRequest(new ipcmMessageForward(IPCM_MSG_REQ_FORWARD,
-                                                aReceiverID,
-                                                aTarget,
-                                                (const char *) aData,
-                                                aDataLen));
-
-  return rv;
-}
-
-struct WaitMessageSelectorData
-{
-  PRUint32             senderID;
-  ipcIMessageObserver *observer;
-};
-
-static PRBool WaitMessageSelector(void *arg, ipcTargetData *td, const ipcMessage *msg)
-{
-  WaitMessageSelectorData *data = (WaitMessageSelectorData *) arg;
-
-  nsresult rv = IPC_WAIT_NEXT_MESSAGE;
-
-  if (msg->mMetaData == data->senderID)
-  {
-    ipcIMessageObserver *obs = data->observer;
-    if (!obs)
-      obs = td->observer;
-    NS_ASSERTION(obs, "must at least have a default observer");
-
-    rv = obs->OnMessageAvailable(msg->mMetaData,
-                                 msg->Target(),
-                                 (const PRUint8 *) msg->Data(),
-                                 msg->DataLen());
-  }
-
-  // stop iterating if we got a match that the observer accepted.
-  return rv != IPC_WAIT_NEXT_MESSAGE;
-}
-
-nsresult
-IPC_WaitMessage(PRUint32             aSenderID,
-                const nsID          &aTarget,
-                ipcIMessageObserver *aObserver,
-                PRIntervalTime       aTimeout)
-{
-  NS_ENSURE_TRUE(gClientState, NS_ERROR_NOT_INITIALIZED);
-
-  // do not permit waiting for IPCM messages
-  if (aTarget.Equals(IPCM_TARGET))
-    return NS_ERROR_INVALID_ARG;
-
-  WaitMessageSelectorData data = { aSenderID, aObserver };
-
-  ipcMessage *msg;
-  nsresult rv = WaitTarget(aTarget, aTimeout, &msg, WaitMessageSelector, &data);
-  if (NS_FAILED(rv))
-    return rv;
-  delete msg;
-
-  return NS_OK;
-}
-
-/* ------------------------------------------------------------------------- */
-
-nsresult
-IPC_GetID(PRUint32 *aClientID)
-{
-  NS_ENSURE_TRUE(gClientState, NS_ERROR_NOT_INITIALIZED);
-
-  *aClientID = gClientState->selfID;
-  return NS_OK;
-}
-
-nsresult
-IPC_AddName(const char *aName)
-{
-  NS_ENSURE_TRUE(gClientState, NS_ERROR_NOT_INITIALIZED);
-
-  return MakeIPCMRequest(new ipcmMessageClientAddName(aName));
-}
-
-nsresult
-IPC_RemoveName(const char *aName)
-{
-  NS_ENSURE_TRUE(gClientState, NS_ERROR_NOT_INITIALIZED);
-
-  return MakeIPCMRequest(new ipcmMessageClientDelName(aName));
-}
-
-/* ------------------------------------------------------------------------- */
-
-nsresult
-IPC_AddClientObserver(ipcIClientObserver *aObserver)
-{
-  NS_ENSURE_TRUE(gClientState, NS_ERROR_NOT_INITIALIZED);
-
-  return gClientState->clientObservers.AppendObject(aObserver)
-      ? NS_OK : NS_ERROR_OUT_OF_MEMORY;
-}
-
-nsresult
-IPC_RemoveClientObserver(ipcIClientObserver *aObserver)
-{
-  NS_ENSURE_TRUE(gClientState, NS_ERROR_NOT_INITIALIZED);
-
-  for (PRInt32 i = 0; i < gClientState->clientObservers.Count(); ++i)
-  {
-    if (gClientState->clientObservers[i] == aObserver)
-      gClientState->clientObservers.RemoveObjectAt(i);
-  }
-
-  return NS_OK;
-}
-
-/* ------------------------------------------------------------------------- */
-
-// this function could be called on any thread
-nsresult
-IPC_ResolveClientName(const char *aName, PRUint32 *aClientID)
-{
-  NS_ENSURE_TRUE(gClientState, NS_ERROR_NOT_INITIALIZED);
-
-  ipcMessage *msg;
-
-  nsresult rv = MakeIPCMRequest(new ipcmMessageQueryClientByName(aName), &msg);
-  if (NS_FAILED(rv))
-    return rv;
-
-  if (IPCM_GetType(msg) == IPCM_MSG_ACK_CLIENT_ID)
-    *aClientID = ipcMessageCast<ipcmMessageClientID>(msg)->ClientID();
-  else
-  {
-    LOG(("unexpected IPCM response: type=%x\n", IPCM_GetType(msg)));
-    rv = NS_ERROR_UNEXPECTED;
-  }
-    
-  delete msg;
-  return rv;
-}
-
-/* ------------------------------------------------------------------------- */
-
-nsresult
-IPC_ClientExists(PRUint32 aClientID, PRBool *aResult)
-{
-  // this is a bit of a hack.  we forward a PING to the specified client.
-  // the assumption is that the forwarding will only succeed if the client
-  // exists, so we wait for the RESULT message corresponding to the FORWARD
-  // request.  if that gives a successful status, then we know that the
-  // client exists.
-
-  ipcmMessagePing ping;
-
-  return MakeIPCMRequest(new ipcmMessageForward(IPCM_MSG_REQ_FORWARD,
-                                                aClientID,
-                                                IPCM_TARGET,
-                                                ping.Data(),
-                                                ping.DataLen()));
-}
-
-/* ------------------------------------------------------------------------- */
-
-nsresult
-IPC_SpawnDaemon(const char *path)
-{
-  PRFileDesc *readable = nsnull, *writable = nsnull;
-  PRProcessAttr *attr = nsnull;
-  nsresult rv = NS_ERROR_FAILURE;
-  char *const argv[] = { (char *const) path, nsnull };
-  char c;
-
-  // setup an anonymous pipe that we can use to determine when the daemon
-  // process has started up.  the daemon will write a char to the pipe, and
-  // when we read it, we'll know to proceed with trying to connect to the
-  // daemon.
-
-  if (PR_CreatePipe(&readable, &writable) != PR_SUCCESS)
-    goto end;
-  PR_SetFDInheritable(writable, PR_TRUE);
-
-  attr = PR_NewProcessAttr();
-  if (!attr)
-    goto end;
-
-  if (PR_ProcessAttrSetInheritableFD(attr, writable, IPC_STARTUP_PIPE_NAME) != PR_SUCCESS)
-    goto end;
-
-  if (PR_CreateProcessDetached(path, argv, nsnull, attr) != PR_SUCCESS)
-    goto end;
-
-  if ((PR_Read(readable, &c, 1) != 1) && (c != IPC_STARTUP_PIPE_MAGIC))
-    goto end;
-
-  rv = NS_OK;
-end:
-  if (readable)
-    PR_Close(readable);
-  if (writable)
-    PR_Close(writable);
-  if (attr)
-    PR_DestroyProcessAttr(attr);
-  return rv;
-}
-
-/* ------------------------------------------------------------------------- */
-
-static PLDHashOperator
-EnumerateTargetMapAndNotify(const nsID    &aKey,
-                            ipcTargetData *aData,
-                            void          *aClosure)
-{
-  nsAutoMonitor mon(aData->monitor);
-
-  // wake up anyone waiting on this target.
-  mon.NotifyAll();
-
-  return PL_DHASH_NEXT;
-}
-
-// called on a background thread
-void
-IPC_OnConnectionEnd(nsresult error)
-{
-  // now, go through the target map, and tickle each monitor.  that should
-  // unblock any calls to WaitTarget.
-
-  nsAutoMonitor mon(gClientState->monitor);
-  gClientState->connected = PR_FALSE;
-  gClientState->targetMap.EnumerateRead(EnumerateTargetMapAndNotify, nsnull);
-}
-
-/* ------------------------------------------------------------------------- */
-
-#ifdef IPC_LOGGING
-#include "prprf.h"
-#include <ctype.h>
-#endif
-
-// called on a background thread
-void
-IPC_OnMessageAvailable(ipcMessage *msg)
-{
-#ifdef IPC_LOGGING
-  if (LOG_ENABLED())
-  {
-    char *targetStr = msg->Target().ToString();
-    LOG(("got message for target: %s\n", targetStr));
-    nsMemory::Free(targetStr);
-
-    IPC_LogBinary((const PRUint8 *) msg->Data(), msg->DataLen());
-  }
-#endif
-
-  if (msg->Target().Equals(IPCM_TARGET))
-  {
-    switch (IPCM_GetType(msg))
-    {
-      // if this is a forwarded message, then post the inner message instead.
-      case IPCM_MSG_PSH_FORWARD:
-      {
-        ipcMessageCast<ipcmMessageForward> fwd(msg);
-        ipcMessage *innerMsg = new ipcMessage(fwd->InnerTarget(),
-                                              fwd->InnerData(),
-                                              fwd->InnerDataLen());
-        // store the sender's client id in the meta-data field of the message.
-        innerMsg->mMetaData = fwd->ClientID();
-
-        delete msg;
-
-        // recurse so we can handle forwarded IPCM messages
-        IPC_OnMessageAvailable(innerMsg);
-        return;
-      }
-      case IPCM_MSG_PSH_CLIENT_STATE:
-      {
-        ipcMessageCast<ipcmMessageClientState> status(msg);
-        nsCOMPtr<nsIRunnable> ev =
-            new ipcEvent_ClientState(status->ClientID(),
-                                     status->ClientState());
-        NS_DispatchToMainThread(ev);
-        return;
-      }
-    }
-  }
-
-  nsRefPtr<ipcTargetData> td;
-  if (GetTarget(msg->Target(), getter_AddRefs(td)))
-  {
-    nsAutoMonitor mon(td->monitor);
-
-    // we only want to dispatch a 'ProcessPendingQ' event if we have not
-    // already done so.
-    PRBool dispatchEvent = td->pendingQ.IsEmpty();
-
-    // put this message on our pending queue
-    td->pendingQ.Append(msg);
-
-    // make copy of target since |msg| may end up pointing to free'd memory
-    // once we notify the monitor.
-    const nsID target = msg->Target();
-
-    LOG(("placed message on pending queue for target and notifying all...\n"));
-
-    // wake up anyone waiting on this queue
-    mon.NotifyAll();
-
-    // proxy call to target's message procedure
-    if (dispatchEvent)
-      CallProcessPendingQ(target, td);
-  }
-  else
-  {
-    NS_WARNING("message target is undefined");
-  }
-}
deleted file mode 100644
--- a/ipc/ipcd/daemon/public/Makefile.in
+++ /dev/null
@@ -1,52 +0,0 @@
-# vim: noexpandtab ts=4 sw=4
-# ***** 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 IPC.
-#
-# The Initial Developer of the Original Code is
-# Netscape Communications Corporation.
-# Portions created by the Initial Developer are Copyright (C) 2002
-# the Initial Developer. All Rights Reserved.
-#
-# Contributor(s):
-#   Darin Fisher <darin@netscape.com>
-#
-# Alternatively, the contents of this file may be used under the terms of
-# either 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 *****
-
-DEPTH		= ../../../..
-topsrcdir	= @top_srcdir@
-srcdir		= @srcdir@
-VPATH		= @srcdir@
-
-include $(DEPTH)/config/autoconf.mk
-
-MODULE		= ipcd
-EXPORTS     = \
-            ipcModule.h \
-            ipcModuleUtil.h \
-            $(NULL)
-
-include $(topsrcdir)/config/rules.mk
deleted file mode 100644
--- a/ipc/ipcd/daemon/public/ipcModule.h
+++ /dev/null
@@ -1,240 +0,0 @@
-/* ***** 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 IPC.
- *
- * The Initial Developer of the Original Code is
- * Netscape Communications Corporation.
- * Portions created by the Initial Developer are Copyright (C) 2002
- * the Initial Developer. All Rights Reserved.
- *
- * Contributor(s):
- *   Darin Fisher <darin@netscape.com>
- *
- * Alternatively, the contents of this file may be used under the terms of
- * either 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 ipcModule_h__
-#define ipcModule_h__
-
-#include "nsID.h"
-
-//
-// a client handle is used to efficiently reference a client instance object
-// used by the daemon to represent a connection with a particular client app.
-//
-// modules should treat it as an opaque type.
-//
-typedef class ipcClient *ipcClientHandle;
-
-//-----------------------------------------------------------------------------
-// interface implemented by the module:
-//-----------------------------------------------------------------------------
-
-//
-// the version of ipcModuleMethods data structure.
-//
-#define IPC_MODULE_METHODS_VERSION (1<<16) // 1.0
-
-//
-// each module defines the following structure:
-//
-struct ipcModuleMethods
-{
-    //
-    // this field holds the version of the data structure, which is always the
-    // value of IPC_MODULE_METHODS_VERSION against which the module was built.
-    //
-    PRUint32 version;
-
-    //
-    // called after this module is registered.
-    //
-    void (* init) (void);
-
-    //
-    // called when this module will no longer be accessed.
-    //
-    void (* shutdown) (void);
-
-    //
-    // called when a new message arrives for this module.
-    //
-    // params:
-    //   client  - an opaque "handle" to an object representing the client that
-    //             sent the message.  modules should not store the value of this
-    //             beyond the duration fo this function call.  (e.g., the handle
-    //             may be invalid after this function call returns.)  modules
-    //             wishing to hold onto a reference to a "client" should store
-    //             the client's ID (see IPC_GetClientID).
-    //   target  - message target
-    //   data    - message data
-    //   dataLen - message data length
-    //
-    void (* handleMsg) (ipcClientHandle client,
-                        const nsID     &target,
-                        const void     *data,
-                        PRUint32        dataLen);
-
-    //
-    // called when a new client connects to the IPC daemon.
-    //
-    void (* clientUp) (ipcClientHandle client);
-
-    //
-    // called when a client disconnects from the IPC daemon.
-    //
-    void (* clientDown) (ipcClientHandle client);
-};
-
-//-----------------------------------------------------------------------------
-// interface implemented by the daemon:
-//-----------------------------------------------------------------------------
-
-//
-// the version of ipcDaemonMethods data structure.
-//
-#define IPC_DAEMON_METHODS_VERSION (1<<16) // 1.0
-
-//
-// enumeration functions may return FALSE to stop enumeration.
-//
-typedef PRBool (* ipcClientEnumFunc)       (void *closure, ipcClientHandle client, PRUint32 clientID);
-typedef PRBool (* ipcClientNameEnumFunc)   (void *closure, ipcClientHandle client, const char *name);
-typedef PRBool (* ipcClientTargetEnumFunc) (void *closure, ipcClientHandle client, const nsID &target);
-
-//
-// the daemon provides the following structure:
-//
-struct ipcDaemonMethods
-{
-    PRUint32 version;
-
-    //
-    // called to send a message to another module.
-    //
-    // params:
-    //   client  - identifies the client from which this message originated.
-    //   target  - message target
-    //   data    - message data
-    //   dataLen - message data length
-    //
-    // returns:
-    //   PR_SUCCESS if message was dispatched.
-    //   PR_FAILURE if message could not be dispatched (possibly because
-    //              no module is registered for the given message target).
-    //
-    PRStatus (* dispatchMsg) (ipcClientHandle client, 
-                              const nsID     &target,
-                              const void     *data,
-                              PRUint32        dataLen);
-
-    //
-    // called to send a message to a particular client or to broadcast a
-    // message to all clients.
-    //
-    // params:
-    //   client  - if null, then broadcast message to all clients.  otherwise,
-    //             send message to the client specified.
-    //   target  - message target
-    //   data    - message data
-    //   dataLen - message data length
-    //
-    // returns:
-    //   PR_SUCCESS if message was sent (or queued up to be sent later).
-    //   PR_FAILURE if message could not be sent (possibly because the client
-    //              does not have a registered observer for the msg's target).
-    //
-    PRStatus (* sendMsg) (ipcClientHandle client,
-                          const nsID     &target,
-                          const void     *data,
-                          PRUint32        dataLen);
-
-    //
-    // called to lookup a client handle given its client ID.  each client has
-    // a unique ID.
-    //
-    ipcClientHandle (* getClientByID) (PRUint32 clientID);
-
-    //
-    // called to lookup a client by name or alias.  names are not necessary
-    // unique to individual clients.  this function returns the client first
-    // registered under the given name.
-    //
-    ipcClientHandle (* getClientByName) (const char *name);
-
-    //
-    // called to enumerate all clients.
-    //
-    void (* enumClients) (ipcClientEnumFunc func, void *closure);
-
-    //
-    // returns the client ID of the specified client.
-    //
-    PRUint32 (* getClientID) (ipcClientHandle client);
-
-    //
-    // functions for inspecting the names and targets defined for a particular
-    // client instance.
-    //
-    PRBool (* clientHasName)     (ipcClientHandle client, const char *name);
-    PRBool (* clientHasTarget)   (ipcClientHandle client, const nsID &target);
-    void   (* enumClientNames)   (ipcClientHandle client, ipcClientNameEnumFunc func, void *closure);
-    void   (* enumClientTargets) (ipcClientHandle client, ipcClientTargetEnumFunc func, void *closure);
-};
-
-//-----------------------------------------------------------------------------
-// interface exported by a DSO implementing one or more modules:
-//-----------------------------------------------------------------------------
-
-struct ipcModuleEntry
-{
-    //
-    // identifies the message target of this module.
-    //
-    nsID target;
-
-    //
-    // module methods
-    //
-    ipcModuleMethods *methods;
-};
-
-//-----------------------------------------------------------------------------
-
-#define IPC_EXPORT extern "C" NS_EXPORT
-
-//
-// IPC_EXPORT int IPC_GetModules(const ipcDaemonMethods *, const ipcModuleEntry **);
-//
-// params:
-//   methods - the daemon's methods
-//   entries - the module entries defined by the DSO
-//
-// returns:
-//   length of the |entries| array.
-//
-typedef int (* ipcGetModulesFunc) (const ipcDaemonMethods *methods, const ipcModuleEntry **entries);
-
-#endif // !ipcModule_h__
deleted file mode 100644
--- a/ipc/ipcd/daemon/public/ipcModuleUtil.h
+++ /dev/null
@@ -1,151 +0,0 @@
-/* ***** 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 IPC.
- *
- * The Initial Developer of the Original Code is
- * Netscape Communications Corporation.
- * Portions created by the Initial Developer are Copyright (C) 2002
- * the Initial Developer. All Rights Reserved.
- *
- * Contributor(s):
- *   Darin Fisher <darin@netscape.com>
- *
- * Alternatively, the contents of this file may be used under the terms of
- * either 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 ipcModuleUtil_h__
-#define ipcModuleUtil_h__
-
-#include "prlog.h"
-#include "ipcModule.h"
-
-extern const ipcDaemonMethods *gIPCDaemonMethods;
-
-//-----------------------------------------------------------------------------
-// inline wrapper functions
-// 
-// these functions may only be called by a module that uses the
-// IPC_IMPL_GETMODULES macro.
-//-----------------------------------------------------------------------------
-
-inline PRStatus
-IPC_DispatchMsg(ipcClientHandle client, const nsID &target, const void *data, PRUint32 dataLen)
-{
-    PR_ASSERT(gIPCDaemonMethods);
-    return gIPCDaemonMethods->dispatchMsg(client, target, data, dataLen);
-}
-
-inline PRStatus
-IPC_SendMsg(ipcClientHandle client, const nsID &target, const void *data, PRUint32 dataLen)
-{
-    PR_ASSERT(gIPCDaemonMethods);
-    return gIPCDaemonMethods->sendMsg(client, target, data, dataLen);
-}
-
-inline ipcClientHandle
-IPC_GetClientByID(PRUint32 id)
-{
-    PR_ASSERT(gIPCDaemonMethods);
-    return gIPCDaemonMethods->getClientByID(id);
-}
-
-inline ipcClientHandle
-IPC_GetClientByName(const char *name)
-{
-    PR_ASSERT(gIPCDaemonMethods);
-    return gIPCDaemonMethods->getClientByName(name);
-}
-
-inline void
-IPC_EnumClients(ipcClientEnumFunc func, void *closure)
-{
-    PR_ASSERT(gIPCDaemonMethods);
-    gIPCDaemonMethods->enumClients(func, closure);
-}
-
-inline PRUint32
-IPC_GetClientID(ipcClientHandle client)
-{
-    PR_ASSERT(gIPCDaemonMethods);
-    return gIPCDaemonMethods->getClientID(client);
-}
-
-inline PRBool
-IPC_ClientHasName(ipcClientHandle client, const char *name)
-{
-    PR_ASSERT(gIPCDaemonMethods);
-    return gIPCDaemonMethods->clientHasName(client, name);
-}
-
-inline PRBool
-IPC_ClientHasTarget(ipcClientHandle client, const nsID &target)
-{
-    PR_ASSERT(gIPCDaemonMethods);
-    return gIPCDaemonMethods->clientHasTarget(client, target);
-}
-
-inline void
-IPC_EnumClientNames(ipcClientHandle client, ipcClientNameEnumFunc func, void *closure)
-{
-    PR_ASSERT(gIPCDaemonMethods);
-    gIPCDaemonMethods->enumClientNames(client, func, closure);
-}
-
-inline void
-IPC_EnumClientTargets(ipcClientHandle client, ipcClientTargetEnumFunc func, void *closure)
-{
-    PR_ASSERT(gIPCDaemonMethods);
-    gIPCDaemonMethods->enumClientTargets(client, func, closure);
-}
-
-//-----------------------------------------------------------------------------
-// inline composite functions
-//-----------------------------------------------------------------------------
-
-inline PRStatus
-IPC_SendMsg(PRUint32 clientID, const nsID &target, const void *data, PRUint32 dataLen)
-{
-    ipcClient *client = IPC_GetClientByID(clientID);
-    if (!client)
-        return PR_FAILURE;
-    return IPC_SendMsg(client, target, data, dataLen);
-}
-
-//-----------------------------------------------------------------------------
-// module factory macros
-//-----------------------------------------------------------------------------
-
-#define IPC_IMPL_GETMODULES(_modName, _modEntries)                  \
-    const ipcDaemonMethods *gIPCDaemonMethods;                      \
-    IPC_EXPORT int                                                  \
-    IPC_GetModules(const ipcDaemonMethods *dmeths,                  \
-                   const ipcModuleEntry **ents) {                   \
-        /* XXX do version checking */                               \
-        gIPCDaemonMethods = dmeths;                                 \
-        *ents = _modEntries;                                        \
-        return sizeof(_modEntries) / sizeof(ipcModuleEntry);        \
-    }
-
-#endif // !ipcModuleUtil_h__
deleted file mode 100644
--- a/ipc/ipcd/daemon/src/Makefile.in
+++ /dev/null
@@ -1,88 +0,0 @@
-# vim: noexpandtab ts=4 sw=4
-# ***** 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 IPC.
-#
-# The Initial Developer of the Original Code is
-# Netscape Communications Corporation.
-# Portions created by the Initial Developer are Copyright (C) 2002
-# the Initial Developer. All Rights Reserved.
-#
-# Contributor(s):
-#   Darin Fisher <darin@netscape.com>
-#
-# Alternatively, the contents of this file may be used under the terms of
-# either 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 *****
-
-DEPTH		= ../../../..
-topsrcdir	= @top_srcdir@
-srcdir		= @srcdir@
-VPATH		= @srcdir@
-
-include $(DEPTH)/config/autoconf.mk
-
-MODULE		= ipcd
-
-# required for #include "nsID.h"
-REQUIRES	= \
-            xpcom \
-            $(NULL)
-
-CPPSRCS		= \
-            ipcd.cpp \
-            ipcClient.cpp \
-            ipcModuleReg.cpp \
-            ipcCommandModule.cpp
-
-ifeq ($(OS_ARCH),WINNT)
-CPPSRCS +=  ipcdWin.cpp
-else
-ifeq ($(OS_ARCH),BeOS)
-CPPSRCS +=  ipcdStub.cpp
-else
-CPPSRCS +=  ipcdUnix.cpp
-endif
-endif
-
-PROGRAM =   mozilla-ipcd$(BIN_SUFFIX)
-
-LOCAL_INCLUDES  = \
-            -I$(srcdir)/../../shared/src \
-            $(NULL)
-
-include $(topsrcdir)/config/config.mk
-
-LIBS		= \
-            $(DIST)/lib/$(LIB_PREFIX)ipcdshared_s.$(LIB_SUFFIX) \
-            $(EXTRA_DSO_LIBS) \
-            $(NSPR_LIBS) \
-            $(NULL)
-
-include $(topsrcdir)/config/rules.mk
-
-# For fruncate
-ifeq ($(OS_ARCH),Linux)
-DEFINES += -D_BSD_SOURCE
-endif
deleted file mode 100644
--- a/ipc/ipcd/daemon/src/ipcClient.cpp
+++ /dev/null
@@ -1,233 +0,0 @@
-/* ***** 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 IPC.
- *
- * The Initial Developer of the Original Code is
- * Netscape Communications Corporation.
- * Portions created by the Initial Developer are Copyright (C) 2002
- * the Initial Developer. All Rights Reserved.
- *
- * Contributor(s):
- *   Darin Fisher <darin@netscape.com>
- *
- * Alternatively, the contents of this file may be used under the terms of
- * either 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 "ipcLog.h"
-#include "ipcClient.h"
-#include "ipcMessage.h"
-#include "ipcModuleReg.h"
-#include "ipcd.h"
-#include "ipcm.h"
-
-#if defined(XP_UNIX) || defined(XP_OS2)
-#include "prio.h"
-#endif
-
-PRUint32 ipcClient::gLastID = 0;
-
-//
-// called to initialize this client context
-//
-// assumptions:
-//  - object's memory has already been zero'd out.
-//
-void
-ipcClient::Init()
-{
-    mID = ++gLastID;
-
-    // every client must be able to handle IPCM messages.
-    mTargets.Append(IPCM_TARGET);
-
-    // although it is tempting to fire off the NotifyClientUp event at this
-    // time, we must wait until the client sends us a CLIENT_HELLO event.
-    // see ipcCommandModule::OnClientHello.
-}
-
-//
-// called when this client context is going away
-//
-void
-ipcClient::Finalize()
-{
-    IPC_NotifyClientDown(this);
-
-    mNames.DeleteAll();
-    mTargets.DeleteAll();
-
-#if defined(XP_UNIX) || defined(XP_OS2)
-    mInMsg.Reset();
-    mOutMsgQ.DeleteAll();
-#endif
-}
-
-void
-ipcClient::AddName(const char *name)
-{
-    LOG(("adding client name: %s\n", name));
-
-    if (HasName(name))
-        return;
-
-    mNames.Append(name);
-}
-
-void
-ipcClient::DelName(const char *name)
-{
-    LOG(("deleting client name: %s\n", name));
-
-    mNames.FindAndDelete(name);
-}
-
-void
-ipcClient::AddTarget(const nsID &target)
-{
-    LOG(("adding client target\n"));
-
-    if (HasTarget(target))
-        return;
-
-    mTargets.Append(target);
-}
-
-void
-ipcClient::DelTarget(const nsID &target)
-{
-    LOG(("deleting client target\n"));
-
-    //
-    // cannot remove the IPCM target
-    //
-    if (!target.Equals(IPCM_TARGET))
-        mTargets.FindAndDelete(target);
-}
-
-#if defined(XP_UNIX) || defined(XP_OS2)
-
-//
-// called to process a client socket
-//
-// params:
-//   fd         - the client socket
-//   poll_flags - the state of the client socket
-//
-// return:
-//   0             - to end session with this client
-//   PR_POLL_READ  - to wait for the client socket to become readable
-//   PR_POLL_WRITE - to wait for the client socket to become writable
-//
-int
-ipcClient::Process(PRFileDesc *fd, int inFlags)
-{
-    if (inFlags & (PR_POLL_ERR    | PR_POLL_HUP |
-                   PR_POLL_EXCEPT | PR_POLL_NVAL)) {
-        LOG(("client socket appears to have closed\n"));
-        return 0;
-    }
-
-    // expect to wait for more data
-    int outFlags = PR_POLL_READ;
-
-    if (inFlags & PR_POLL_READ) {
-        LOG(("client socket is now readable\n"));
-
-        char buf[1024]; // XXX make this larger?
-        PRInt32 n;
-
-        // find out how much data is available for reading...
-        // n = PR_Available(fd);
-
-        n = PR_Read(fd, buf, sizeof(buf));
-        if (n <= 0)
-            return 0; // cancel connection
-
-        const char *ptr = buf;
-        while (n) {
-            PRUint32 nread;
-            PRBool complete;
-
-            if (mInMsg.ReadFrom(ptr, PRUint32(n), &nread, &complete) == PR_FAILURE) {
-                LOG(("message appears to be malformed; dropping client connection\n"));
-                return 0;
-            }
-
-            if (complete) {
-                IPC_DispatchMsg(this, &mInMsg);
-                mInMsg.Reset();
-            }
-
-            n -= nread;
-            ptr += nread;
-        }
-    }
-  
-    if (inFlags & PR_POLL_WRITE) {
-        LOG(("client socket is now writable\n"));
-
-        if (mOutMsgQ.First())
-            WriteMsgs(fd);
-    }
-
-    if (mOutMsgQ.First())
-        outFlags |= PR_POLL_WRITE;
-
-    return outFlags;
-}
-
-//
-// called to write out any messages from the outgoing queue.
-//
-int
-ipcClient::WriteMsgs(PRFileDesc *fd)
-{
-    while (mOutMsgQ.First()) {
-        const char *buf = (const char *) mOutMsgQ.First()->MsgBuf();
-        PRInt32 bufLen = (PRInt32) mOutMsgQ.First()->MsgLen();
-
-        if (mSendOffset) {
-            buf += mSendOffset;
-            bufLen -= mSendOffset;
-        }
-
-        PRInt32 nw = PR_Write(fd, buf, bufLen);
-        if (nw <= 0)
-            break;
-
-        LOG(("wrote %d bytes\n", nw));
-
-        if (nw == bufLen) {
-            mOutMsgQ.DeleteFirst();
-            mSendOffset = 0;
-        }
-        else
-            mSendOffset += nw;
-    }
-
-    return 0;
-}
-
-#endif
deleted file mode 100644
--- a/ipc/ipcd/daemon/src/ipcClient.h
+++ /dev/null
@@ -1,144 +0,0 @@
-/* ***** 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 IPC.
- *
- * The Initial Developer of the Original Code is
- * Netscape Communications Corporation.
- * Portions created by the Initial Developer are Copyright (C) 2002
- * the Initial Developer. All Rights Reserved.
- *
- * Contributor(s):
- *   Darin Fisher <darin@netscape.com>
- *
- * Alternatively, the contents of this file may be used under the terms of
- * either 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 ipcClientUnix_h__
-#define ipcClientUnix_h__
-
-#include "prio.h"
-#include "ipcMessageQ.h"
-#include "ipcStringList.h"
-#include "ipcIDList.h"
-
-#ifdef XP_WIN
-#include <windows.h>
-#endif
-
-//-----------------------------------------------------------------------------
-// ipcClient
-//
-// NOTE: this class is an implementation detail of the IPC daemon. IPC daemon
-// modules (other than the built-in IPCM module) must not access methods on
-// this class directly. use the API provided via ipcd.h instead.
-//-----------------------------------------------------------------------------
-
-class ipcClient
-{
-public:
-    void Init();
-    void Finalize();
-
-    PRUint32 ID() const { return mID; }
-
-    void   AddName(const char *name);
-    void   DelName(const char *name);
-    PRBool HasName(const char *name) const { return mNames.Find(name) != NULL; }
-
-    void   AddTarget(const nsID &target);
-    void   DelTarget(const nsID &target);
-    PRBool HasTarget(const nsID &target) const { return mTargets.Find(target) != NULL; }
-
-    // list iterators
-    const ipcStringNode *Names()   const { return mNames.First(); }
-    const ipcIDNode     *Targets() const { return mTargets.First(); }
-
-    // returns primary client name (the one specified in the "client hello" message)
-    const char *PrimaryName() const { return mNames.First() ? mNames.First()->Value() : NULL; }
-
-    void   SetExpectsSyncReply(PRBool val) { mExpectsSyncReply = val; }
-    PRBool GetExpectsSyncReply() const     { return mExpectsSyncReply; }
-
-#ifdef XP_WIN
-    PRUint32 PID() const { return mPID; }
-    void SetPID(PRUint32 pid) { mPID = pid; }
-
-    HWND Hwnd() const { return mHwnd; }
-    void SetHwnd(HWND hwnd) { mHwnd = hwnd; }
-#endif
-
-#if defined(XP_UNIX) || defined(XP_OS2)
-    //
-    // called to process a client file descriptor.  the value of pollFlags
-    // indicates the state of the socket.
-    //
-    // returns:
-    //   0             - to cancel client connection  
-    //   PR_POLL_READ  - to poll for a readable socket
-    //   PR_POLL_WRITE - to poll for a writable socket
-    //   (both flags)  - to poll for either a readable or writable socket
-    //
-    // the socket is non-blocking.
-    // 
-    int Process(PRFileDesc *sockFD, int pollFlags);
-
-    //
-    // on success or failure, this function takes ownership of |msg| and will
-    // delete it when appropriate.
-    //
-    void EnqueueOutboundMsg(ipcMessage *msg) { mOutMsgQ.Append(msg); }
-#endif
-
-private:
-    static PRUint32 gLastID;
-
-    PRUint32      mID;
-    ipcStringList mNames;
-    ipcIDList     mTargets;
-    PRBool        mExpectsSyncReply;
-
-#ifdef XP_WIN
-    // on windows, we store the PID of the client process to help us determine
-    // the client from which a message originated.  each message has the PID
-    // encoded in it.
-    PRUint32      mPID;
-    
-    // the hwnd of the client's message window.
-    HWND          mHwnd;
-#endif
-
-#if defined(XP_UNIX) || defined(XP_OS2)
-    ipcMessage    mInMsg;    // buffer for incoming message
-    ipcMessageQ   mOutMsgQ;  // outgoing message queue
-
-    // keep track of the amount of the first message sent
-    PRUint32      mSendOffset;
-
-    // utility function for writing out messages.
-    int WriteMsgs(PRFileDesc *fd);
-#endif
-};
-
-#endif // !ipcClientUnix_h__
deleted file mode 100644
--- a/ipc/ipcd/daemon/src/ipcCommandModule.cpp
+++ /dev/null
@@ -1,285 +0,0 @@
-/* ***** 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 IPC.
- *
- * The Initial Developer of the Original Code is
- * Netscape Communications Corporation.
- * Portions created by the Initial Developer are Copyright (C) 2002
- * the Initial Developer. All Rights Reserved.
- *
- * Contributor(s):
- *   Darin Fisher <darin@netscape.com>
- *
- * Alternatively, the contents of this file may be used under the terms of
- * either 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 <stdlib.h>
-#include <string.h>
-#include "ipcLog.h"
-#include "ipcCommandModule.h"
-#include "ipcModule.h"
-#include "ipcClient.h"
-#include "ipcMessage.h"
-#include "ipcMessageUtils.h"
-#include "ipcModuleReg.h"
-#include "ipcd.h"
-#include "ipcm.h"
-
-struct ipcCommandModule
-{
-    typedef void (* MsgHandler)(ipcClient *, const ipcMessage *);
-
-    //
-    // helpers
-    //
-
-    static char **
-    BuildStringArray(const ipcStringNode *nodes)
-    {
-        size_t count = 0;
-
-        const ipcStringNode *node;
-        
-        for (node = nodes; node; node = node->mNext)
-            count++;
-
-        char **strs = (char **) malloc((count + 1) * sizeof(char *));
-        if (!strs)
-            return NULL;
-
-        count = 0;
-        for (node = nodes; node; node = node->mNext, ++count)
-            strs[count] = (char *) node->Value();
-        strs[count] = 0;
-
-        return strs;
-    }
-
-    static nsID **
-    BuildIDArray(const ipcIDNode *nodes)
-    {
-        size_t count = 0;
-
-        const ipcIDNode *node;
-        
-        for (node = nodes; node; node = node->mNext)
-            count++;
-
-        nsID **ids = (nsID **) calloc(count + 1, sizeof(nsID *));
-        if (!ids)
-            return NULL;
-
-        count = 0;
-        for (node = nodes; node; node = node->mNext, ++count)
-            ids[count] = (nsID *) &node->Value();
-
-        return ids;
-    }
-
-    //
-    // message handlers
-    //
-
-    static void
-    OnPing(ipcClient *client, const ipcMessage *rawMsg)
-    {
-        LOG(("got PING\n"));
-
-        IPC_SendMsg(client, new ipcmMessageResult(IPCM_GetRequestIndex(rawMsg), IPCM_OK));
-    }
-
-    static void
-    OnClientHello(ipcClient *client, const ipcMessage *rawMsg)
-    {
-        LOG(("got CLIENT_HELLO\n"));
-
-        IPC_SendMsg(client, new ipcmMessageClientID(IPCM_GetRequestIndex(rawMsg), client->ID()));
-
-        //
-        // NOTE: it would almost make sense for this notification to live
-        // in the transport layer code.  however, clients expect to receive
-        // a CLIENT_ID as the first message following a CLIENT_HELLO, so we
-        // must not allow modules to see a client until after we have sent
-        // the CLIENT_ID message.
-        //
-        IPC_NotifyClientUp(client);
-    }
-
-    static void
-    OnClientAddName(ipcClient *client, const ipcMessage *rawMsg)
-    {
-        LOG(("got CLIENT_ADD_NAME\n"));
-
-        ipcMessageCast<ipcmMessageClientAddName> msg(rawMsg);
-        const char *name = msg->Name();
-        if (name)
-            client->AddName(name);
-
-        // TODO: send better status code (e.g., suppose name already defined for client)
-        IPC_SendMsg(client, new ipcmMessageResult(IPCM_GetRequestIndex(rawMsg), IPCM_OK));
-    }
-
-    static void
-    OnClientDelName(ipcClient *client, const ipcMessage *rawMsg)
-    {
-        LOG(("got CLIENT_DEL_NAME\n"));
-
-        ipcMessageCast<ipcmMessageClientDelName> msg(rawMsg);
-        const char *name = msg->Name();
-        if (name)
-            client->DelName(name);
-
-        // TODO: send better status code (e.g., suppose name not defined for client)
-        IPC_SendMsg(client, new ipcmMessageResult(IPCM_GetRequestIndex(rawMsg), IPCM_OK));
-    }
-
-    static void
-    OnClientAddTarget(ipcClient *client, const ipcMessage *rawMsg)
-    {
-        LOG(("got CLIENT_ADD_TARGET\n"));
-
-        ipcMessageCast<ipcmMessageClientAddTarget> msg(rawMsg);
-        client->AddTarget(msg->Target());
-
-        // TODO: send better status code (e.g., suppose target already defined for client)
-        IPC_SendMsg(client, new ipcmMessageResult(IPCM_GetRequestIndex(rawMsg), IPCM_OK));
-    }
-
-    static void
-    OnClientDelTarget(ipcClient *client, const ipcMessage *rawMsg)
-    {
-        LOG(("got CLIENT_DEL_TARGET\n"));
-
-        ipcMessageCast<ipcmMessageClientDelTarget> msg(rawMsg);
-        client->DelTarget(msg->Target());
-
-        // TODO: send better status code (e.g., suppose target not defined for client)
-        IPC_SendMsg(client, new ipcmMessageResult(IPCM_GetRequestIndex(rawMsg), IPCM_OK));
-    }
-
-    static void
-    OnQueryClientByName(ipcClient *client, const ipcMessage *rawMsg)
-    {
-        LOG(("got QUERY_CLIENT_BY_NAME\n"));
-
-        PRUint32 requestIndex = IPCM_GetRequestIndex(rawMsg);
-
-        ipcMessageCast<ipcmMessageQueryClientByName> msg(rawMsg);
-
-        ipcClient *result = IPC_GetClientByName(msg->Name());
-        if (result) {
-            LOG(("  client exists w/ ID = %u\n", result->ID()));
-            IPC_SendMsg(client, new ipcmMessageClientID(requestIndex, result->ID()));
-        }
-        else {
-            LOG(("  client does not exist\n"));
-            IPC_SendMsg(client, new ipcmMessageResult(requestIndex, IPCM_ERROR_NO_CLIENT));
-        }
-    }
-
-#if 0
-    static void
-    OnQueryClientInfo(ipcClient *client, const ipcMessage *rawMsg)
-    {
-        LOG(("got QUERY_CLIENT_INFO\n"));
-
-        ipcMessageCast<ipcmMessageQueryClientInfo> msg(rawMsg);
-        ipcClient *result = IPC_GetClientByID(msg->ClientID());
-        if (result) {
-            char **names = BuildStringArray(result->Names());
-            nsID **targets = BuildIDArray(result->Targets());
-
-            IPC_SendMsg(client, new ipcmMessageClientInfo(result->ID(),
-                                                          msg->RequestIndex(),
-                                                          (const char **) names,
-                                                          (const nsID **) targets));
-
-            free(names);
-            free(targets);
-        }
-        else {
-            LOG(("  client does not exist\n"));
-            IPC_SendMsg(client, new ipcmMessageError(IPCM_ERROR_CLIENT_NOT_FOUND, msg->RequestIndex()));
-        }
-    }
-#endif
-
-    static void
-    OnForward(ipcClient *client, const ipcMessage *rawMsg)
-    {
-        LOG(("got FORWARD\n"));
-
-        ipcMessageCast<ipcmMessageForward> msg(rawMsg);
-
-        ipcClient *dest = IPC_GetClientByID(msg->ClientID());
-        if (!dest) {
-            LOG(("  destination client not found!\n"));
-            IPC_SendMsg(client, new ipcmMessageResult(IPCM_GetRequestIndex(rawMsg), IPCM_ERROR_NO_CLIENT));
-            return;
-        }
-        // inform client that its message will be forwarded
-        IPC_SendMsg(client, new ipcmMessageResult(IPCM_GetRequestIndex(rawMsg), IPCM_OK));
-
-        ipcMessage *newMsg = new ipcmMessageForward(IPCM_MSG_PSH_FORWARD,
-                                                    client->ID(),
-                                                    msg->InnerTarget(),
-                                                    msg->InnerData(),
-                                                    msg->InnerDataLen());
-        IPC_SendMsg(dest, newMsg);
-    }
-};
-
-void
-IPCM_HandleMsg(ipcClient *client, const ipcMessage *rawMsg)
-{
-    static ipcCommandModule::MsgHandler handlers[] =
-    {
-        ipcCommandModule::OnPing,
-        ipcCommandModule::OnForward,
-        ipcCommandModule::OnClientHello,
-        ipcCommandModule::OnClientAddName,
-        ipcCommandModule::OnClientDelName,
-        ipcCommandModule::OnClientAddTarget,
-        ipcCommandModule::OnClientDelTarget,
-        ipcCommandModule::OnQueryClientByName
-    };
-
-    int type = IPCM_GetType(rawMsg);
-    LOG(("IPCM_HandleMsg [type=%x]\n", type));
-
-    if (!(type & IPCM_MSG_CLASS_REQ)) {
-        LOG(("not a request -- ignoring message\n"));
-        return;
-    }
-
-    type &= ~IPCM_MSG_CLASS_REQ;
-    type--;
-    if (type < 0 || type >= (int) (sizeof(handlers)/sizeof(handlers[0]))) {
-        LOG(("unknown request -- ignoring message\n")); 
-        return;
-    }
-
-    (handlers[type])(client, rawMsg);
-}
deleted file mode 100644
--- a/ipc/ipcd/daemon/src/ipcCommandModule.h
+++ /dev/null
@@ -1,48 +0,0 @@
-/* ***** 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 IPC.
- *
- * The Initial Developer of the Original Code is
- * Netscape Communications Corporation.
- * Portions created by the Initial Developer are Copyright (C) 2002
- * the Initial Developer. All Rights Reserved.
- *
- * Contributor(s):
- *   Darin Fisher <darin@netscape.com>
- *
- * Alternatively, the contents of this file may be used under the terms of
- * either 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 ipcCommandModule_h__
-#define ipcCommandModule_h__
-
-#include "ipcm.h" // for IPCM_TARGET
-
-class ipcClient;
-class ipcMessage;
-
-void IPCM_HandleMsg(ipcClient *, const ipcMessage *);
-
-#endif // !ipcCommandModule_h__
deleted file mode 100644
--- a/ipc/ipcd/daemon/src/ipcModuleReg.cpp
+++ /dev/null
@@ -1,245 +0,0 @@
-/* ***** 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 IPC.
- *
- * The Initial Developer of the Original Code is
- * Netscape Communications Corporation.
- * Portions created by the Initial Developer are Copyright (C) 2002
- * the Initial Developer. All Rights Reserved.
- *
- * Contributor(s):
- *   Darin Fisher <darin@netscape.com>
- *
- * Alternatively, the contents of this file may be used under the terms of
- * either 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 <string.h>
-#include <stdlib.h>
-
-#include "prlink.h"
-#include "prio.h"
-#include "prlog.h"
-#include "plstr.h"
-
-#include "ipcConfig.h"
-#include "ipcLog.h"
-#include "ipcModuleReg.h"
-#include "ipcModule.h"
-#include "ipcCommandModule.h"
-#include "ipcd.h"
-
-//-----------------------------------------------------------------------------
-
-struct ipcModuleRegEntry
-{
-    nsID              target;
-    ipcModuleMethods *methods;
-    PRLibrary        *lib;
-};
-
-#define IPC_MAX_MODULE_COUNT 64
-
-static ipcModuleRegEntry ipcModules[IPC_MAX_MODULE_COUNT];
-static int ipcModuleCount = 0;
-
-//-----------------------------------------------------------------------------
-
-static PRStatus
-AddModule(const nsID &target, ipcModuleMethods *methods, const char *libPath)
-{
-    if (ipcModuleCount == IPC_MAX_MODULE_COUNT) {
-        LOG(("too many modules!\n"));
-        return PR_FAILURE;
-    }
-
-    if (!methods) {
-        PR_NOT_REACHED("null module methods");
-        return PR_FAILURE;
-    }
-
-    //
-    // each ipcModuleRegEntry holds a reference to a PRLibrary, and on
-    // shutdown, each PRLibrary reference will be released.  this ensures
-    // that the library will not be unloaded until all of the modules in
-    // that library are shutdown.
-    //
-    ipcModules[ipcModuleCount].target = target;
-    ipcModules[ipcModuleCount].methods = methods;
-    ipcModules[ipcModuleCount].lib = PR_LoadLibrary(libPath);
-
-    ++ipcModuleCount;
-    return PR_SUCCESS;
-}
-
-static void
-InitModuleFromLib(const char *modulesDir, const char *fileName)
-{
-    LOG(("InitModuleFromLib [%s]\n", fileName));
-
-    static const ipcDaemonMethods gDaemonMethods =
-    {
-        IPC_DAEMON_METHODS_VERSION,
-        IPC_DispatchMsg,
-        IPC_SendMsg,
-        IPC_GetClientByID,
-        IPC_GetClientByName,
-        IPC_EnumClients,
-        IPC_GetClientID,
-        IPC_ClientHasName,
-        IPC_ClientHasTarget,
-        IPC_EnumClientNames,
-        IPC_EnumClientTargets
-    };
-
-    int dLen = strlen(modulesDir);
-    int fLen = strlen(fileName);
-
-    char *buf = (char *) malloc(dLen + 1 + fLen + 1);
-    memcpy(buf, modulesDir, dLen);
-    buf[dLen] = IPC_PATH_SEP_CHAR;
-    memcpy(buf + dLen + 1, fileName, fLen);
-    buf[dLen + 1 + fLen] = '\0';
-
-    PRLibrary *lib = PR_LoadLibrary(buf);
-    if (lib) {
-        ipcGetModulesFunc func =
-            (ipcGetModulesFunc) PR_FindFunctionSymbol(lib, "IPC_GetModules");
-
-        LOG(("  func=%p\n", (void*) func));
-
-        if (func) {
-            const ipcModuleEntry *entries = NULL;
-            int count = func(&gDaemonMethods, &entries);
-            for (int i=0; i<count; ++i) {
-                if (AddModule(entries[i].target, entries[i].methods, buf) == PR_SUCCESS) {
-                    if (entries[i].methods->init)
-                        entries[i].methods->init();
-                }
-            }
-        }
-        PR_UnloadLibrary(lib);
-    }
-
-    free(buf);
-}
-
-//-----------------------------------------------------------------------------
-// ipcModuleReg API
-//-----------------------------------------------------------------------------
-
-void
-IPC_InitModuleReg(const char *exePath)
-{
-    if (!(exePath && *exePath))
-        return;
-
-    //
-    // register plug-in modules
-    //
-    char *p = PL_strrchr(exePath, IPC_PATH_SEP_CHAR);
-    if (p == NULL) {
-        LOG(("unexpected exe path\n"));
-        return;
-    }
-
-    int baseLen = p - exePath;
-    int finalLen = baseLen + 1 + sizeof(IPC_MODULES_DIR);
-
-    // build full path to ipc modules
-    char *modulesDir = (char*) malloc(finalLen);
-    memcpy(modulesDir, exePath, baseLen);
-    modulesDir[baseLen] = IPC_PATH_SEP_CHAR;
-    memcpy(modulesDir + baseLen + 1, IPC_MODULES_DIR, sizeof(IPC_MODULES_DIR));
-
-    LOG(("loading libraries in %s\n", modulesDir));
-    // 
-    // scan directory for IPC modules
-    //
-    PRDir *dir = PR_OpenDir(modulesDir);
-    if (dir) {
-        PRDirEntry *ent;
-        while ((ent = PR_ReadDir(dir, PR_SKIP_BOTH)) != NULL) {
-            // 
-            // locate extension, and check if dynamic library
-            //
-
-            const char *p = strrchr(ent->name, '.');
-            if (p && PL_strcasecmp(p, MOZ_DLL_SUFFIX) == 0)
-                InitModuleFromLib(modulesDir, ent->name);
-        }
-        PR_CloseDir(dir);
-    }
-
-    free(modulesDir);
-}
-
-void
-IPC_ShutdownModuleReg()
-{
-    //
-    // shutdown modules in reverse order    
-    //
-    while (ipcModuleCount) {
-        ipcModuleRegEntry &entry = ipcModules[--ipcModuleCount];
-        if (entry.methods->shutdown)
-            entry.methods->shutdown();
-        if (entry.lib)
-            PR_UnloadLibrary(entry.lib);
-    }
-}
-
-void
-IPC_NotifyModulesClientUp(ipcClient *client)
-{
-    for (int i = 0; i < ipcModuleCount; ++i) {
-        ipcModuleRegEntry &entry = ipcModules[i];
-        if (entry.methods->clientUp)
-            entry.methods->clientUp(client);
-    }
-}
-
-void
-IPC_NotifyModulesClientDown(ipcClient *client)
-{
-    for (int i = 0; i < ipcModuleCount; ++i) {
-        ipcModuleRegEntry &entry = ipcModules[i];
-        if (entry.methods->clientDown)
-            entry.methods->clientDown(client);
-    }
-}
-
-PRStatus
-IPC_DispatchMsg(ipcClient *client, const nsID &target, const void *data, PRUint32 dataLen)
-{
-    // dispatch message to every module registered under the given target.
-    for (int i=0; i<ipcModuleCount; ++i) {
-        ipcModuleRegEntry &entry = ipcModules[i];
-        if (entry.target.Equals(target)) {
-            if (entry.methods->handleMsg)
-                entry.methods->handleMsg(client, target, data, dataLen);
-        }
-    }
-    return PR_SUCCESS;
-}
deleted file mode 100644
--- a/ipc/ipcd/daemon/src/ipcModuleReg.h
+++ /dev/null
@@ -1,70 +0,0 @@
-/* ***** 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 IPC.
- *
- * The Initial Developer of the Original Code is
- * Netscape Communications Corporation.
- * Portions created by the Initial Developer are Copyright (C) 2002
- * the Initial Developer. All Rights Reserved.
- *
- * Contributor(s):
- *   Darin Fisher <darin@netscape.com>
- *
- * Alternatively, the contents of this file may be used under the terms of
- * either 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 ipcModuleReg_h__
-#define ipcModuleReg_h__
-
-#include "ipcModule.h"
-
-//
-// called to init the module registry.  this may only be called once at
-// startup or once after calling IPC_ShutdownModuleReg.
-//
-// params:
-//   exePath - path to the daemon executable.  modules are loaded from a
-//             directory relative to the daemon executable.
-//
-void IPC_InitModuleReg(const char *exePath);
-
-//
-// called to shutdown the module registry.  this may be called more than
-// once and need not follow a call to IPC_InitModuleReg.
-//
-void IPC_ShutdownModuleReg();
-
-//
-// returns the ipcModuleMethods for the given target.
-//
-ipcModuleMethods *IPC_GetModuleByTarget(const nsID &target);
-
-//
-// notifies all modules of client connect/disconnect
-//
-void IPC_NotifyModulesClientUp(ipcClient *);
-void IPC_NotifyModulesClientDown(ipcClient *);
-
-#endif // !ipcModuleReg_h__
deleted file mode 100644
--- a/ipc/ipcd/daemon/src/ipcd.cpp
+++ /dev/null
@@ -1,231 +0,0 @@
-/* ***** 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 IPC.
- *
- * The Initial Developer of the Original Code is
- * Netscape Communications Corporation.
- * Portions created by the Initial Developer are Copyright (C) 2002
- * the Initial Developer. All Rights Reserved.
- *
- * Contributor(s):
- *   Darin Fisher <darin@netscape.com>
- *
- * Alternatively, the contents of this file may be used under the terms of
- * either 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 "prlog.h"
-#include "prio.h"
-
-#include "ipcConfig.h"
-#include "ipcLog.h"
-#include "ipcMessage.h"
-#include "ipcClient.h"
-#include "ipcModuleReg.h"
-#include "ipcModule.h"
-#include "ipcCommandModule.h"
-#include "ipcdPrivate.h"
-#include "ipcd.h"
-
-//-----------------------------------------------------------------------------
-
-void
-IPC_NotifyParent()
-{
-    PRFileDesc *fd = PR_GetInheritedFD(IPC_STARTUP_PIPE_NAME);
-    if (fd) {
-        char c = IPC_STARTUP_PIPE_MAGIC;
-        PR_Write(fd, &c, 1);
-        PR_Close(fd);
-    }
-}
-
-//-----------------------------------------------------------------------------
-
-PRStatus
-IPC_DispatchMsg(ipcClient *client, const ipcMessage *msg)
-{
-    PR_ASSERT(client);
-    PR_ASSERT(msg);
-
-    // remember if client is expecting SYNC_REPLY.  we'll add that flag to the
-    // next message sent to the client.
-    if (msg->TestFlag(IPC_MSG_FLAG_SYNC_QUERY)) {
-        PR_ASSERT(client->GetExpectsSyncReply() == PR_FALSE);
-        // XXX shouldn't we remember the TargetID as well, and only set the
-        //     SYNC_REPLY flag on the next message sent to the same TargetID?
-        client->SetExpectsSyncReply(PR_TRUE);
-    }
-
-    if (msg->Target().Equals(IPCM_TARGET)) {
-        IPCM_HandleMsg(client, msg);
-        return PR_SUCCESS;
-    }
-
-    return IPC_DispatchMsg(client, msg->Target(), msg->Data(), msg->DataLen());
-}
-
-PRStatus
-IPC_SendMsg(ipcClient *client, ipcMessage *msg)
-{
-    PR_ASSERT(msg);
-
-    if (client == NULL) {
-        //
-        // broadcast
-        //
-        for (int i=0; i<ipcClientCount; ++i)
-            IPC_SendMsg(&ipcClients[i], msg->Clone());
-        delete msg;
-        return PR_SUCCESS;
-    }
-
-    // add SYNC_REPLY flag to message if client is expecting...
-    if (client->GetExpectsSyncReply()) {
-        msg->SetFlag(IPC_MSG_FLAG_SYNC_REPLY);
-        client->SetExpectsSyncReply(PR_FALSE);
-    }
-
-    if (client->HasTarget(msg->Target()))
-        return IPC_PlatformSendMsg(client, msg);
-
-    LOG(("  no registered message handler\n"));
-    return PR_FAILURE;
-}
-
-void
-IPC_NotifyClientUp(ipcClient *client)
-{
-    // notify modules before other clients
-    IPC_NotifyModulesClientUp(client);
-
-    for (int i=0; i<ipcClientCount; ++i) {
-        if (&ipcClients[i] != client)
-            IPC_SendMsg(&ipcClients[i],
-                new ipcmMessageClientState(client->ID(), IPCM_CLIENT_STATE_UP));
-    }
-}
-
-void
-IPC_NotifyClientDown(ipcClient *client)
-{
-    // notify modules before other clients
-    IPC_NotifyModulesClientDown(client);
-
-    for (int i=0; i<ipcClientCount; ++i) {
-        if (&ipcClients[i] != client)
-            IPC_SendMsg(&ipcClients[i],
-                new ipcmMessageClientState(client->ID(), IPCM_CLIENT_STATE_DOWN));
-    }
-}
-
-//-----------------------------------------------------------------------------
-// IPC daemon methods
-//-----------------------------------------------------------------------------
-
-PRStatus
-IPC_SendMsg(ipcClient *client, const nsID &target, const void *data, PRUint32 dataLen)
-{
-    return IPC_SendMsg(client, new ipcMessage(target, (const char *) data, dataLen));
-}
-
-ipcClient *
-IPC_GetClientByID(PRUint32 clientID)
-{
-    // linear search OK since number of clients should be small
-    for (int i = 0; i < ipcClientCount; ++i) {
-        if (ipcClients[i].ID() == clientID)
-            return &ipcClients[i];
-    }
-    return NULL;
-}
-
-ipcClient *
-IPC_GetClientByName(const char *name)
-{
-    // linear search OK since number of clients should be small
-    for (int i = 0; i < ipcClientCount; ++i) {
-        if (ipcClients[i].HasName(name))
-            return &ipcClients[i];
-    }
-    return NULL;
-}
-
-void
-IPC_EnumClients(ipcClientEnumFunc func, void *closure)
-{
-    PR_ASSERT(func);
-    for (int i = 0; i < ipcClientCount; ++i) {
-        if (func(closure, &ipcClients[i], ipcClients[i].ID()) == PR_FALSE)
-            break;
-    }
-}
-
-PRUint32
-IPC_GetClientID(ipcClient *client)
-{
-    PR_ASSERT(client);
-    return client->ID();
-}
-
-PRBool
-IPC_ClientHasName(ipcClient *client, const char *name)
-{
-    PR_ASSERT(client);
-    PR_ASSERT(name);
-    return client->HasName(name);
-}
-
-PRBool
-IPC_ClientHasTarget(ipcClient *client, const nsID &target)
-{
-    PR_ASSERT(client);
-    return client->HasTarget(target);
-}
-
-void
-IPC_EnumClientNames(ipcClient *client, ipcClientNameEnumFunc func, void *closure)
-{
-    PR_ASSERT(client);
-    PR_ASSERT(func);
-    const ipcStringNode *node = client->Names();
-    while (node) {
-        if (func(closure, client, node->Value()) == PR_FALSE)
-            break;
-        node = node->mNext;
-    }
-}
-
-void
-IPC_EnumClientTargets(ipcClient *client, ipcClientTargetEnumFunc func, void *closure)
-{
-    PR_ASSERT(client);
-    PR_ASSERT(func);
-    const ipcIDNode *node = client->Targets();
-    while (node) {
-        if (func(closure, client, node->Value()) == PR_FALSE)
-            break;
-        node = node->mNext;
-    }
-}
deleted file mode 100644
--- a/ipc/ipcd/daemon/src/ipcd.h
+++ /dev/null
@@ -1,82 +0,0 @@
-/* ***** 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 IPC.
- *
- * The Initial Developer of the Original Code is
- * Netscape Communications Corporation.
- * Portions created by the Initial Developer are Copyright (C) 2002
- * the Initial Developer. All Rights Reserved.
- *
- * Contributor(s):
- *   Darin Fisher <darin@netscape.com>
- *
- * Alternatively, the contents of this file may be used under the terms of
- * either 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 IPCD_H__
-#define IPCD_H__
-
-#include "ipcModule.h"
-#include "ipcMessage.h"
-
-//-----------------------------------------------------------------------------
-// IPC daemon methods (see struct ipcDaemonMethods)
-//
-// these functions may only be called directly from within the daemon.  plug-in
-// modules must access these through the ipcDaemonMethods structure.
-//-----------------------------------------------------------------------------
-
-PRStatus        IPC_DispatchMsg          (ipcClientHandle client, const nsID &target, const void *data, PRUint32 dataLen);
-PRStatus        IPC_SendMsg              (ipcClientHandle client, const nsID &target, const void *data, PRUint32 dataLen);
-ipcClientHandle IPC_GetClientByID        (PRUint32 id);
-ipcClientHandle IPC_GetClientByName      (const char *name);
-void            IPC_EnumClients          (ipcClientEnumFunc func, void *closure);
-PRUint32        IPC_GetClientID          (ipcClientHandle client);
-PRBool          IPC_ClientHasName        (ipcClientHandle client, const char *name);
-PRBool          IPC_ClientHasTarget      (ipcClientHandle client, const nsID &target);
-void            IPC_EnumClientNames      (ipcClientHandle client, ipcClientNameEnumFunc func, void *closure);
-void            IPC_EnumClientTargets    (ipcClientHandle client, ipcClientTargetEnumFunc func, void *closure);
-
-//-----------------------------------------------------------------------------
-// other internal IPCD methods
-//-----------------------------------------------------------------------------
-
-//
-// dispatch message
-//
-PRStatus IPC_DispatchMsg(ipcClientHandle client, const ipcMessage *msg);
-
-//
-// send message, takes ownership of |msg|.
-//
-PRStatus IPC_SendMsg(ipcClientHandle client, ipcMessage *msg);
-
-//
-// dispatch notifications about client connects and disconnects
-//
-void IPC_NotifyClientUp(ipcClientHandle client);
-void IPC_NotifyClientDown(ipcClientHandle client);
-
-#endif // !IPCD_H__
deleted file mode 100644
--- a/ipc/ipcd/daemon/src/ipcdPrivate.h
+++ /dev/null
@@ -1,65 +0,0 @@
-/* ***** 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 IPC.
- *
- * The Initial Developer of the Original Code is
- * Netscape Communications Corporation.
- * Portions created by the Initial Developer are Copyright (C) 2002
- * the Initial Developer. All Rights Reserved.
- *
- * Contributor(s):
- *   Darin Fisher <darin@netscape.com>
- *
- * Alternatively, the contents of this file may be used under the terms of
- * either 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 ipcdPrivate_h__
-#define ipcdPrivate_h__
-
-class ipcClient;
-
-//
-// upper limit on the number of active connections
-// XXX may want to make this more dynamic
-//
-#define IPC_MAX_CLIENTS 100
-
-//
-// array of connected clients
-//
-extern ipcClient *ipcClients;
-extern int        ipcClientCount;
-
-//
-// platform specific send message function, takes ownership of |msg|.
-//
-PRStatus IPC_PlatformSendMsg(ipcClient  *client, ipcMessage *msg);
-
-//
-// notify parent that it can connect to the daemon.
-//
-void IPC_NotifyParent();
-
-#endif // !ipcdPrivate_h__
deleted file mode 100644
--- a/ipc/ipcd/daemon/src/ipcdStub.cpp
+++ /dev/null
@@ -1,77 +0,0 @@
-/* ***** 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 IPC.
- *
- * The Initial Developer of the Original Code is IBM Corporation.
- * Portions created by IBM Corporation are Copyright (C) 2003
- * IBM Corporation. All Rights Reserved.
- *
- * Contributor(s):
- *   Darin Fisher <darin@meer.net>
- *
- * Alternatively, the contents of this file may be used under the terms of
- * either 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 "ipcd.h"
-#include "ipcdPrivate.h"
-#include "ipcLog.h"
-
-#include "prerror.h"
-
-//-----------------------------------------------------------------------------
-// use this file as a template to add server-side IPC connectivity.
-// 
-// NOTE: if your platform supports local domain TCP sockets, then you should
-//       be able to make use of ipcConnectionUnix.cpp.
-//-----------------------------------------------------------------------------
-
-// these variables are declared in ipcdPrivate.h and must be initialized by
-// when the daemon starts up.
-ipcClient *ipcClients = NULL;
-int        ipcClientCount = 0;
-
-PRStatus
-IPC_PlatformSendMsg(ipcClient  *client, ipcMessage *msg)
-{
-    const char notimplemented[] = "IPC_PlatformSendMsg not implemented";
-    PR_SetErrorText(sizeof(notimplemented), notimplemented);
-    return PR_FAILURE;
-}
-
-int main(int argc, char **argv)
-{
-    IPC_InitLog("###");
-
-    LOG(("daemon started...\n"));
-
-    /*
-    IPC_InitModuleReg(argv[0]);
-    IPC_ShutdownModuleReg();
-    */
-
-    // let the parent process know that we are up-and-running
-    IPC_NotifyParent();
-    return 0;
-}
deleted file mode 100644
--- a/ipc/ipcd/daemon/src/ipcdUnix.cpp
+++ /dev/null
@@ -1,463 +0,0 @@
-/* ***** 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 IPC.
- *
- * The Initial Developer of the Original Code is
- * Netscape Communications Corporation.
- * Portions created by the Initial Developer are Copyright (C) 2002
- * the Initial Developer. All Rights Reserved.
- *
- * Contributor(s):
- *   Darin Fisher <darin@netscape.com>
- *
- * Alternatively, the contents of this file may be used under the terms of
- * either 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 <sys/types.h>
-#include <sys/stat.h>
-#include <unistd.h>
-#include <fcntl.h>
-#include <signal.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-
-#include "prio.h"
-#include "prerror.h"
-#include "prthread.h"
-#include "prinrval.h"
-#include "plstr.h"
-#include "prprf.h"
-
-#include "ipcConfig.h"
-#include "ipcLog.h"
-#include "ipcMessage.h"
-#include "ipcClient.h"
-#include "ipcModuleReg.h"
-#include "ipcdPrivate.h"
-#include "ipcd.h"
-
-#if 0
-static void
-IPC_Sleep(int seconds)
-{
-    while (seconds > 0) {
-        LOG(("\rsleeping for %d seconds...", seconds));
-        PR_Sleep(PR_SecondsToInterval(1));
-        --seconds;
-    }
-    LOG(("\ndone sleeping\n"));
-}
-#endif
-
-//-----------------------------------------------------------------------------
-// ipc directory and locking...
-//-----------------------------------------------------------------------------
-
-//
-// advisory file locking is used to ensure that only one IPC daemon is active
-// and bound to the local domain socket at a time.
-//
-// XXX this code does not work on OS/2.
-//
-#if !defined(XP_OS2)
-#define IPC_USE_FILE_LOCK
-#endif
-
-#ifdef IPC_USE_FILE_LOCK
-
-static int ipcLockFD = 0;
-
-static PRBool AcquireDaemonLock(const char *baseDir)
-{
-    const char lockName[] = "lock";
-
-    int dirLen = strlen(baseDir);
-    int len = dirLen            // baseDir
-            + 1                 // "/"
-            + sizeof(lockName); // "lock"
-
-    char *lockFile = (char *) malloc(len);
-    memcpy(lockFile, baseDir, dirLen);
-    lockFile[dirLen] = '/';
-    memcpy(lockFile + dirLen + 1, lockName, sizeof(lockName));
-
-    // 
-    // open lock file.  it remains open until we shutdown.
-    //
-    ipcLockFD = open(lockFile, O_WRONLY|O_CREAT, S_IWUSR|S_IRUSR);
-
-    free(lockFile);
-
-    if (ipcLockFD == -1)
-        return PR_FALSE;
-
-    //
-    // we use fcntl for locking.  assumption: filesystem should be local.
-    // this API is nice because the lock will be automatically released
-    // when the process dies.  it will also be released when the file
-    // descriptor is closed.
-    //
-    struct flock lock;
-    lock.l_type = F_WRLCK;
-    lock.l_start = 0;
-    lock.l_len = 0;
-    lock.l_whence = SEEK_SET;
-    if (fcntl(ipcLockFD, F_SETLK, &lock) == -1)
-        return PR_FALSE;
-
-    //
-    // truncate lock file once we have exclusive access to it.
-    //
-    ftruncate(ipcLockFD, 0);
-
-    //
-    // write our PID into the lock file (this just seems like a good idea...
-    // no real purpose otherwise).
-    //
-    char buf[32];
-    int nb = PR_snprintf(buf, sizeof(buf), "%u\n", (unsigned long) getpid());
-    write(ipcLockFD, buf, nb);
-
-    return PR_TRUE;
-}
-
-static PRBool InitDaemonDir(const char *socketPath)
-{
-    LOG(("InitDaemonDir [sock=%s]\n", socketPath));
-
-    char *baseDir = PL_strdup(socketPath);
-
-    //
-    // make sure IPC directory exists (XXX this should be recursive)
-    //
-    char *p = strrchr(baseDir, '/');
-    if (p)
-        p[0] = '\0';
-    mkdir(baseDir, 0700);
-
-    //
-    // if we can't acquire the daemon lock, then another daemon
-    // must be active, so bail.
-    //
-    PRBool haveLock = AcquireDaemonLock(baseDir);
-
-    PL_strfree(baseDir);
-
-    if (haveLock) {
-        // delete an existing socket to prevent bind from failing.
-        unlink(socketPath);
-    }
-    return haveLock;
-}
-
-static void ShutdownDaemonDir()
-{
-    LOG(("ShutdownDaemonDir\n"));
-
-    // deleting directory and files underneath it allows another process
-    // to think it has exclusive access.  better to just leave the hidden
-    // directory in /tmp and let the OS clean it up via the usual tmpdir
-    // cleanup cron job.
-
-    // this removes the advisory lock, allowing other processes to acquire it.
-    if (ipcLockFD) {
-        close(ipcLockFD);
-        ipcLockFD = 0;
-    }
-}
-
-#endif // IPC_USE_FILE_LOCK
-
-//-----------------------------------------------------------------------------
-// poll list
-//-----------------------------------------------------------------------------
-
-//
-// declared in ipcdPrivate.h
-//
-ipcClient *ipcClients = NULL;
-int        ipcClientCount = 0;
-
-//
-// the first element of this array is always zero; this is done so that the
-// k'th element of ipcClientArray corresponds to the k'th element of
-// ipcPollList.
-//
-static ipcClient ipcClientArray[IPC_MAX_CLIENTS + 1];
-
-//
-// element 0 contains the "server socket"
-//
-static PRPollDesc ipcPollList[IPC_MAX_CLIENTS + 1];
-
-//-----------------------------------------------------------------------------
-
-static int AddClient(PRFileDesc *fd)
-{
-    if (ipcClientCount == IPC_MAX_CLIENTS) {
-        LOG(("reached maximum client limit\n"));
-        return -1;
-    }
-
-    int pollCount = ipcClientCount + 1;
-
-    ipcClientArray[pollCount].Init();
-
-    ipcPollList[pollCount].fd = fd;
-    ipcPollList[pollCount].in_flags = PR_POLL_READ;
-    ipcPollList[pollCount].out_flags = 0;
-
-    ++ipcClientCount;
-    return 0;
-}
-
-static int RemoveClient(int clientIndex)
-{
-    PRPollDesc *pd = &ipcPollList[clientIndex];
-
-    PR_Close(pd->fd);
-
-    ipcClientArray[clientIndex].Finalize();
-
-    //
-    // keep the clients and poll_fds contiguous; move the last one into
-    // the spot held by the one that is going away.
-    //
-    int toIndex = clientIndex;
-    int fromIndex = ipcClientCount;
-    if (fromIndex != toIndex) {
-        memcpy(&ipcClientArray[toIndex], &ipcClientArray[fromIndex], sizeof(ipcClient));
-        memcpy(&ipcPollList[toIndex], &ipcPollList[fromIndex], sizeof(PRPollDesc));
-    }
-
-    //
-    // zero out the old entries.
-    //
-    memset(&ipcClientArray[fromIndex], 0, sizeof(ipcClient));
-    memset(&ipcPollList[fromIndex], 0, sizeof(PRPollDesc));
-
-    --ipcClientCount;
-    return 0;
-}
-
-//-----------------------------------------------------------------------------
-
-static void PollLoop(PRFileDesc *listenFD)
-{
-    // the first element of ipcClientArray is unused.
-    memset(ipcClientArray, 0, sizeof(ipcClientArray));
-    ipcClients = ipcClientArray + 1;
-    ipcClientCount = 0;
-
-    ipcPollList[0].fd = listenFD;
-    ipcPollList[0].in_flags = PR_POLL_EXCEPT | PR_POLL_READ;
-    
-    while (1) {
-        PRInt32 rv;
-        PRIntn i;
-
-        int pollCount = ipcClientCount + 1;
-
-        ipcPollList[0].out_flags = 0;
-
-        //
-        // poll
-        //
-        // timeout after 5 minutes.  if no connections after timeout, then
-        // exit.  this timeout ensures that we don't stay resident when no
-        // clients are interested in connecting after spawning the daemon.
-        //
-        // XXX add #define for timeout value
-        //
-        LOG(("calling PR_Poll [pollCount=%d]\n", pollCount));
-        rv = PR_Poll(ipcPollList, pollCount, PR_SecondsToInterval(60 * 5));
-        if (rv == -1) {
-            LOG(("PR_Poll failed [%d]\n", PR_GetError()));
-            return;
-        }
-
-        if (rv > 0) {
-            //
-            // process clients that are ready
-            //
-            for (i = 1; i < pollCount; ++i) {
-                if (ipcPollList[i].out_flags != 0) {
-                    ipcPollList[i].in_flags =
-                        ipcClientArray[i].Process(ipcPollList[i].fd,
-                                                  ipcPollList[i].out_flags);
-                    ipcPollList[i].out_flags = 0;
-                }
-            }
-
-            //
-            // cleanup any dead clients (indicated by a zero in_flags)
-            //
-            for (i = pollCount - 1; i >= 1; --i) {
-                if (ipcPollList[i].in_flags == 0)
-                    RemoveClient(i);
-            }
-
-            //
-            // check for new connection
-            //
-            if (ipcPollList[0].out_flags & PR_POLL_READ) {
-                LOG(("got new connection\n"));
-
-                PRNetAddr clientAddr;
-                memset(&clientAddr, 0, sizeof(clientAddr));
-                PRFileDesc *clientFD;
-
-                clientFD = PR_Accept(listenFD, &clientAddr, PR_INTERVAL_NO_WAIT);
-                if (clientFD == NULL) {
-                    // ignore this error... perhaps the client disconnected.
-                    LOG(("PR_Accept failed [%d]\n", PR_GetError()));
-                }
-                else {
-                    // make socket non-blocking
-                    PRSocketOptionData opt;
-                    opt.option = PR_SockOpt_Nonblocking;
-                    opt.value.non_blocking = PR_TRUE;
-                    PR_SetSocketOption(clientFD, &opt);
-
-                    if (AddClient(clientFD) != 0)
-                        PR_Close(clientFD);
-                }
-            }
-        }
-
-        //
-        // shutdown if no clients
-        //
-        if (ipcClientCount == 0) {
-            LOG(("shutting down\n"));
-            break;
-        }
-    }
-}
-
-//-----------------------------------------------------------------------------
-
-PRStatus
-IPC_PlatformSendMsg(ipcClient  *client, ipcMessage *msg)
-{
-    LOG(("IPC_PlatformSendMsg\n"));
-
-    //
-    // must copy message onto send queue.
-    //
-    client->EnqueueOutboundMsg(msg);
-
-    //
-    // since our Process method may have already been called, we must ensure
-    // that the PR_POLL_WRITE flag is set.
-    //
-    int clientIndex = client - ipcClientArray;
-    ipcPollList[clientIndex].in_flags |= PR_POLL_WRITE;
-
-    return PR_SUCCESS;
-}
-
-//-----------------------------------------------------------------------------
-
-int main(int argc, char **argv)
-{
-    PRFileDesc *listenFD = NULL;
-    PRNetAddr addr;
-
-    //
-    // ignore SIGINT so <ctrl-c> from terminal only kills the client
-    // which spawned this daemon.
-    //
-    signal(SIGINT, SIG_IGN);
-    // XXX block others?  check cartman
-
-    // ensure strict file permissions
-    umask(0077);
-
-    IPC_InitLog("###");
-
-    LOG(("daemon started...\n"));
-
-    //XXX uncomment these lines to test slow starting daemon
-    //IPC_Sleep(2);
-
-    // set socket address
-    addr.local.family = PR_AF_LOCAL;
-    if (argc < 2)
-        IPC_GetDefaultSocketPath(addr.local.path, sizeof(addr.local.path));
-    else
-        PL_strncpyz(addr.local.path, argv[1], sizeof(addr.local.path));
-
-#ifdef IPC_USE_FILE_LOCK
-    if (!InitDaemonDir(addr.local.path)) {
-        LOG(("InitDaemonDir failed\n"));
-        goto end;
-    }
-#endif
-
-    listenFD = PR_OpenTCPSocket(PR_AF_LOCAL);
-    if (!listenFD) {
-        LOG(("PR_OpenTCPSocket failed [%d]\n", PR_GetError()));
-        goto end;
-    }
-
-    if (PR_Bind(listenFD, &addr) != PR_SUCCESS) {
-        LOG(("PR_Bind failed [%d]\n", PR_GetError()));
-        goto end;
-    }
-
-    IPC_InitModuleReg(argv[0]);
-
-    if (PR_Listen(listenFD, 5) != PR_SUCCESS) {
-        LOG(("PR_Listen failed [%d]\n", PR_GetError()));
-        goto end;
-    }
-
-    IPC_NotifyParent();
-
-    PollLoop(listenFD);
-
-end:
-    IPC_ShutdownModuleReg();
-
-    IPC_NotifyParent();
-
-    //IPC_Sleep(5);
-
-#ifdef IPC_USE_FILE_LOCK
-    // it is critical that we release the lock before closing the socket,
-    // otherwise, a client might launch another daemon that would be unable
-    // to acquire the lock and would then leave the client without a daemon.
- 
-    ShutdownDaemonDir();
-#endif
-
-    if (listenFD) {
-        LOG(("closing socket\n"));
-        PR_Close(listenFD);
-    }
-    return 0;
-}
deleted file mode 100644
--- a/ipc/ipcd/daemon/src/ipcdWin.cpp
+++ /dev/null
@@ -1,408 +0,0 @@
-/* ***** 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 IPC.
- *
- * The Initial Developer of the Original Code is
- * Netscape Communications Corporation.
- * Portions created by the Initial Developer are Copyright (C) 2002
- * the Initial Developer. All Rights Reserved.
- *
- * Contributor(s):
- *   Darin Fisher <darin@netscape.com>
- *
- * Alternatively, the contents of this file may be used under the terms of
- * either 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 <windows.h>
-
-#include "prthread.h"
-
-#include "ipcConfig.h"
-#include "ipcLog.h"
-#include "ipcMessage.h"
-#include "ipcClient.h"
-#include "ipcModuleReg.h"
-#include "ipcdPrivate.h"
-#include "ipcd.h"
-#include "ipcm.h"
-
-//
-// declared in ipcdPrivate.h
-//
-ipcClient *ipcClients = NULL;
-int        ipcClientCount = 0;
-
-static ipcClient ipcClientArray[IPC_MAX_CLIENTS];
-
-static HWND   ipcHwnd = NULL;
-static PRBool ipcShutdown = PR_FALSE;
-
-#define IPC_PURGE_TIMER_ID 1
-#define IPC_WM_SENDMSG  (WM_USER + 1)
-#define IPC_WM_SHUTDOWN (WM_USER + 2)
-
-//-----------------------------------------------------------------------------
-// client array manipulation
-//-----------------------------------------------------------------------------
-
-static void
-RemoveClient(ipcClient *client)
-{
-    LOG(("RemoveClient\n"));
-
-    int clientIndex = client - ipcClientArray;
-
-    client->Finalize();
-
-    //
-    // move last ipcClient object down into the spot occupied by this client.
-    //
-    int fromIndex = ipcClientCount - 1;
-    int toIndex = clientIndex;
-    if (toIndex != fromIndex)
-        memcpy(&ipcClientArray[toIndex], &ipcClientArray[fromIndex], sizeof(ipcClient));
-
-    memset(&ipcClientArray[fromIndex], 0, sizeof(ipcClient));
-
-    --ipcClientCount;
-    LOG(("  num clients = %u\n", ipcClientCount));
-
-    if (ipcClientCount == 0) {
-        LOG(("  shutting down...\n"));
-        KillTimer(ipcHwnd, IPC_PURGE_TIMER_ID);
-        PostQuitMessage(0);
-        ipcShutdown = PR_TRUE;
-    }
-}
-
-static void
-PurgeStaleClients()
-{
-    if (ipcClientCount == 0)
-        return;
-
-    LOG(("PurgeStaleClients [num-clients=%u]\n", ipcClientCount));
-    //
-    // walk the list of supposedly active clients, and verify the existance of
-    // their respective message windows.
-    //
-    char wName[IPC_CLIENT_WINDOW_NAME_MAXLEN];
-    for (int i=ipcClientCount-1; i>=0; --i) {
-        ipcClient *client = &ipcClientArray[i];
-
-        LOG(("  checking client at index %u [client-id=%u pid=%u]\n", 
-            i, client->ID(), client->PID()));
-
-        IPC_GetClientWindowName(client->PID(), wName);
-
-        // XXX dougt has ideas about how to make this better
-
-        HWND hwnd = FindWindow(IPC_CLIENT_WINDOW_CLASS, wName);
-        if (!hwnd) {
-            LOG(("  client window not found; removing client!\n"));
-            RemoveClient(client);
-        }
-    }
-}
-
-static ipcClient *
-AddClient(HWND hwnd, PRUint32 pid)
-{
-    LOG(("AddClient\n"));
-
-    //
-    // before adding a new client, verify that all existing clients are
-    // still up and running.  remove any stale clients.
-    //
-    PurgeStaleClients();
-
-    if (ipcClientCount == IPC_MAX_CLIENTS) {
-        LOG(("  reached maximum client count!\n"));
-        return NULL;
-    }
-
-    ipcClient *client = &ipcClientArray[ipcClientCount];
-    client->Init();
-    client->SetHwnd(hwnd);
-    client->SetPID(pid);    // XXX one function instead of 3
-
-    ++ipcClientCount;
-    LOG(("  num clients = %u\n", ipcClientCount));
-
-    if (ipcClientCount == 1)
-        SetTimer(ipcHwnd, IPC_PURGE_TIMER_ID, 1000, NULL);
-
-    return client;
-}
-
-static ipcClient *
-GetClientByPID(PRUint32 pid)
-{
-    for (int i=0; i<ipcClientCount; ++i) {
-        if (ipcClientArray[i].PID() == pid)
-            return &ipcClientArray[i];
-    }
-    return NULL;
-}
-
-//-----------------------------------------------------------------------------
-// message processing
-//-----------------------------------------------------------------------------
-
-static void
-ProcessMsg(HWND hwnd, PRUint32 pid, const ipcMessage *msg)
-{
-    LOG(("ProcessMsg [pid=%u len=%u]\n", pid, msg->MsgLen()));
-
-    ipcClient *client = GetClientByPID(pid);
-
-    if (client) {
-        //
-        // if this is an IPCM "client hello" message, then reset the client
-        // instance object.
-        //
-        if (msg->Target().Equals(IPCM_TARGET) &&
-            IPCM_GetType(msg) == IPCM_MSG_REQ_CLIENT_HELLO) {
-            RemoveClient(client);
-            client = NULL;
-        }
-    }
-
-    if (client == NULL) {
-        client = AddClient(hwnd, pid);
-        if (!client)
-            return;
-    }
-
-    IPC_DispatchMsg(client, msg);
-}
-
-//-----------------------------------------------------------------------------
-
-PRStatus
-IPC_PlatformSendMsg(ipcClient  *client, ipcMessage *msg)
-{
-    LOG(("IPC_PlatformSendMsg [clientID=%u clientPID=%u]\n",
-        client->ID(), client->PID()));
-
-    // use PostMessage to make this asynchronous; otherwise we might get
-    // some wierd SendMessage recursion between processes.
-
-    WPARAM wParam = (WPARAM) client->Hwnd();
-    LPARAM lParam = (LPARAM) msg;
-    if (!PostMessage(ipcHwnd, IPC_WM_SENDMSG, wParam, lParam)) {
-        LOG(("PostMessage failed\n"));
-        delete msg;
-        return PR_FAILURE;
-    }
-    return PR_SUCCESS;
-}
-
-//-----------------------------------------------------------------------------
-// windows message loop
-//-----------------------------------------------------------------------------
-
-static LRESULT CALLBACK
-WindowProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
-{
-    LOG(("got message [msg=%x wparam=%x lparam=%x]\n", uMsg, wParam, lParam));
-
-    if (uMsg == WM_COPYDATA) {
-        if (ipcShutdown) {
-            LOG(("ignoring message b/c daemon is shutting down\n"));
-            return TRUE;
-        }
-        COPYDATASTRUCT *cd = (COPYDATASTRUCT *) lParam;
-        if (cd && cd->lpData) {
-            ipcMessage msg;
-            PRUint32 bytesRead;
-            PRBool complete;
-            // XXX avoid extra malloc
-            PRStatus rv = msg.ReadFrom((const char *) cd->lpData, cd->cbData,
-                                       &bytesRead, &complete);
-            if (rv == PR_SUCCESS && complete) {
-                //
-                // grab client PID and hwnd.
-                //
-                ProcessMsg((HWND) wParam, (PRUint32) cd->dwData, &msg);
-            }
-            else
-                LOG(("ignoring malformed message\n"));
-        }
-        return TRUE;
-    }
-
-    if (uMsg == IPC_WM_SENDMSG) {
-        HWND hWndDest = (HWND) wParam;
-        ipcMessage *msg = (ipcMessage *) lParam;
-
-        COPYDATASTRUCT cd;
-        cd.dwData = GetCurrentProcessId();
-        cd.cbData = (DWORD) msg->MsgLen();
-        cd.lpData = (PVOID) msg->MsgBuf();
-
-        LOG(("calling SendMessage...\n"));
-        SendMessage(hWndDest, WM_COPYDATA, (WPARAM) hWnd, (LPARAM) &cd);
-        LOG(("  done.\n"));
-
-        delete msg;
-        return 0;
-    }
-
-    if (uMsg == WM_TIMER) {
-        PurgeStaleClients();
-        return 0;
-    }
-
-#if 0
-    if (uMsg == IPC_WM_SHUTDOWN) {
-        //
-        // since this message is handled asynchronously, it is possible
-        // that other clients may have come online since this was issued.
-        // in which case, we need to ignore this message.
-        //
-        if (ipcClientCount == 0) {
-            ipcShutdown = PR_TRUE;
-            PostQuitMessage(0);
-        }
-        return 0;
-    }
-#endif
-
-    return DefWindowProc(hWnd, uMsg, wParam, lParam);
-}
-
-//-----------------------------------------------------------------------------
-// daemon startup synchronization
-//-----------------------------------------------------------------------------
-
-static HANDLE ipcSyncEvent;
-
-static PRBool
-AcquireLock()
-{
-    ipcSyncEvent = CreateEvent(NULL, FALSE, FALSE,
-                               IPC_SYNC_EVENT_NAME);
-    if (!ipcSyncEvent) {
-        LOG(("CreateEvent failed [%u]\n", GetLastError()));
-        return PR_FALSE;
-    }
-
-    // check to see if event already existed prior to this call.
-    if (GetLastError() == ERROR_ALREADY_EXISTS) {
-        LOG(("  lock already set; exiting...\n"));
-        return PR_FALSE;
-    }
-    
-    LOG(("  acquired lock\n"));
-    return PR_TRUE;
-}
-
-static void
-ReleaseLock()
-{
-    if (ipcSyncEvent) {
-        LOG(("releasing lock...\n"));
-        CloseHandle(ipcSyncEvent);
-        ipcSyncEvent = NULL;
-    }
-}
-
-//-----------------------------------------------------------------------------
-// main
-//-----------------------------------------------------------------------------
-
-#ifdef DEBUG
-int
-main()
-#else
-int WINAPI WinMain(HINSTANCE, HINSTANCE, LPSTR, int)
-#endif
-{
-    IPC_InitLog("###");
-
-    LOG(("daemon started...\n"));
-
-    if (!AcquireLock()) {
-        // unblock the parent; it should be able to find the IPC window of the
-        // other daemon process.
-        IPC_NotifyParent();
-        return 0;
-    }
-
-    // initialize global data
-    memset(ipcClientArray, 0, sizeof(ipcClientArray));
-    ipcClients = ipcClientArray;
-    ipcClientCount = 0;
-
-    // create message window up front...
-    WNDCLASS wc;
-    memset(&wc, 0, sizeof(wc));
-    wc.lpfnWndProc = WindowProc;
-    wc.lpszClassName = IPC_WINDOW_CLASS;
-
-    RegisterClass(&wc);
-
-    ipcHwnd = CreateWindow(IPC_WINDOW_CLASS, IPC_WINDOW_NAME,
-                           0, 0, 0, 10, 10, NULL, NULL, NULL, NULL);
-
-    // unblock the parent process; it should now look for the IPC window.
-    IPC_NotifyParent();
-
-    if (!ipcHwnd)
-        return -1;
-
-    // load modules relative to the location of the executable...
-    {
-        char path[MAX_PATH];
-        GetModuleFileName(NULL, path, sizeof(path));
-        IPC_InitModuleReg(path);
-    }
-
-    LOG(("entering message loop...\n"));
-    MSG msg;
-    while (GetMessage(&msg, ipcHwnd, 0, 0))
-        DispatchMessage(&msg);
-
-    // unload modules
-    IPC_ShutdownModuleReg();
-
-    //
-    // we release the daemon lock before destroying the window because the
-    // absence of our window is what will cause clients to try to spawn the
-    // daemon.
-    //
-    ReleaseLock();
-
-    //LOG(("sleeping 5 seconds...\n"));
-    //PR_Sleep(PR_SecondsToInterval(5));
-
-    LOG(("destroying message window...\n"));
-    DestroyWindow(ipcHwnd);
-    ipcHwnd = NULL;
-
-    LOG(("exiting\n"));
-    return 0;
-}
deleted file mode 100644
--- a/ipc/ipcd/extensions/Makefile.in
+++ /dev/null
@@ -1,49 +0,0 @@
-# vim: noexpandtab ts=4 sw=4
-# ***** 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 IPC.
-#
-# The Initial Developer of the Original Code is
-# Netscape Communications Corporation.
-# Portions created by the Initial Developer are Copyright (C) 2002
-# the Initial Developer. All Rights Reserved.
-#
-# Contributor(s):
-#   Darin Fisher <darin@netscape.com>
-#
-# Alternatively, the contents of this file may be used under the terms of
-# either 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 *****
-
-DEPTH		= ../../..
-topsrcdir	= @top_srcdir@
-srcdir		= @srcdir@
-VPATH		= @srcdir@
-
-include $(DEPTH)/config/autoconf.mk
-
-MODULE		= ipcd
-DIRS        = lock transmngr dconnect
-
-include $(topsrcdir)/config/rules.mk
deleted file mode 100644
--- a/ipc/ipcd/extensions/dconnect/Makefile.in
+++ /dev/null
@@ -1,52 +0,0 @@
-# vim: noexpandtab ts=4 sw=4
-# ***** 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 IPC.
-#
-# The Initial Developer of the Original Code is
-# Netscape Communications Corporation.
-# Portions created by the Initial Developer are Copyright (C) 2002
-# the Initial Developer. All Rights Reserved.
-#
-# Contributor(s):
-#   Darin Fisher <darin@netscape.com>
-#
-# Alternatively, the contents of this file may be used under the terms of
-# either 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 *****
-
-DEPTH		= ../../../..
-topsrcdir	= @top_srcdir@
-srcdir		= @srcdir@
-VPATH		= @srcdir@
-
-include $(DEPTH)/config/autoconf.mk
-
-DIRS        = public src
-
-ifdef ENABLE_TESTS
-DIRS		+= test
-endif
-
-include $(topsrcdir)/config/rules.mk
deleted file mode 100644
--- a/ipc/ipcd/extensions/dconnect/public/Makefile.in
+++ /dev/null
@@ -1,53 +0,0 @@
-# vim: noexpandtab ts=4 sw=4
-# ***** 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 IPC.
-#
-# The Initial Developer of the Original Code is
-# Netscape Communications Corporation.
-# Portions created by the Initial Developer are Copyright (C) 2002
-# the Initial Developer. All Rights Reserved.
-#
-# Contributor(s):
-#   Darin Fisher <darin@netscape.com>
-#
-# Alternatively, the contents of this file may be used under the terms of
-# either 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 *****
-
-DEPTH		= ../../../../..
-topsrcdir	= @top_srcdir@
-srcdir		= @srcdir@
-VPATH		= @srcdir@
-
-include $(DEPTH)/config/autoconf.mk
-
-MODULE		= ipcd
-XPIDL_MODULE= ipcd_dconnect
-
-XPIDLSRCS	= \
-			ipcIDConnectService.idl \
-			$(NULL)
-
-include $(topsrcdir)/config/rules.mk
deleted file mode 100644
--- a/ipc/ipcd/extensions/dconnect/public/ipcIDConnectService.idl
+++ /dev/null
@@ -1,79 +0,0 @@
-/* vim:set ts=2 sw=2 et cindent: */
-/* ***** 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 IPC.
- *
- * The Initial Developer of the Original Code is IBM Corporation.
- * Portions created by the Initial Developer are Copyright (C) 2004
- * the Initial Developer. All Rights Reserved.
- *
- * Contributor(s):
- *   Darin Fisher <darin@meer.net>
- *
- * Alternatively, the contents of this file may be used under the terms of
- * either 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"
-
-/**
- * This service provides methods similar to nsIComponentManager and
- * nsIServiceManager.  A ClientID parameter specifies the remote process
- * in which the object should live.
- *
- * ipcIService can be used to determine the ClientID of a remote process.
- *
- * It is assumed that both processes have access to the same typelibs.
- */
-[scriptable, uuid(fe07ed16-2710-4a1e-a4e2-81302b62bf0e)]
-interface ipcIDConnectService : nsISupports
-{
-  void createInstance(
-    in unsigned long aClientID,
-    in nsCIDRef aClass,
-    in nsIIDRef aIID,
-    [iid_is(aIID),retval] out nsQIResult result
-  );
-
-  void createInstanceByContractID(
-    in unsigned long aClientID,
-    in string aContractID,
-    in nsIIDRef aIID,
-    [iid_is(aIID),retval] out nsQIResult result
-  );
-
-  void getService(
-    in unsigned long aClientID,
-    in nsCIDRef aClass,
-    in nsIIDRef aIID,
-    [iid_is(aIID),retval] out nsQIResult result
-  );
-
-  void getServiceByContractID(
-    in unsigned long aClientID,
-    in string aContractID,
-    in nsIIDRef aIID,
-    [iid_is(aIID),retval] out nsQIResult result
-  );
-};
deleted file mode 100644
--- a/ipc/ipcd/extensions/dconnect/src/Makefile.in
+++ /dev/null
@@ -1,66 +0,0 @@
-# vim: noexpandtab ts=4 sw=4
-# ***** 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 IPC.
-#
-# The Initial Developer of the Original Code is
-# Netscape Communications Corporation.
-# Portions created by the Initial Developer are Copyright (C) 2002
-# the Initial Developer. All Rights Reserved.
-#
-# Contributor(s):
-#   Darin Fisher <darin@netscape.com>
-#
-# Alternatively, the contents of this file may be used under the terms of
-# either 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 *****
-
-DEPTH		= ../../../../..
-topsrcdir	= @top_srcdir@
-srcdir		= @srcdir@
-VPATH		= @srcdir@
-
-include $(DEPTH)/config/autoconf.mk
-
-MODULE				= ipcd
-LIBRARY_NAME		= ipcddconnect_s
-FORCE_STATIC_LIB	= 1
-MODULE_NAME			= ipcd
-LIBXUL_LIBRARY      = 1
-FORCE_USE_PIC	= 1
-
-REQUIRES	= \
-			xpcom \
-			string \
-			$(NULL)
-
-CPPSRCS		= \
-			ipcDConnectService.cpp \
-			$(NULL)
-
-LOCAL_INCLUDES = \
-			-I$(srcdir)/../../../shared/src \
-			$(NULL)
-
-include $(topsrcdir)/config/rules.mk
deleted file mode 100644
--- a/ipc/ipcd/extensions/dconnect/src/ipcDConnectService.cpp
+++ /dev/null
@@ -1,1840 +0,0 @@
-/* vim:set ts=2 sw=2 et cindent: */
-/* ***** 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 IPC.
- *
- * The Initial Developer of the Original Code is IBM Corporation.
- * Portions created by the Initial Developer are Copyright (C) 2004
- * the Initial Developer. All Rights Reserved.
- *
- * Contributor(s):
- *   Darin Fisher <darin@meer.net>
- *
- * Alternatively, the contents of this file may be used under the terms of
- * either 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 <stdio.h>
-
-#include "ipcDConnectService.h"
-#include "ipcMessageWriter.h"
-#include "ipcMessageReader.h"
-#include "ipcLog.h"
-
-#include "nsServiceManagerUtils.h"
-#include "nsIInterfaceInfo.h"
-#include "nsIInterfaceInfoManager.h"
-#include "nsAutoPtr.h"
-#include "nsString.h"
-#include "nsVoidArray.h"
-#include "nsCRT.h"
-#include "xptcall.h"
-
-// XXX TODO:
-//  1. add a client observer and prune mInstances when a peer disconnects
-//  2. add thread affinity field to SETUP messages
-//  3. support array parameters
-
-//-----------------------------------------------------------------------------
-
-#define DCONNECT_IPC_TARGETID                      \
-{ /* 43ca47ef-ebc8-47a2-9679-a4703218089f */       \
-  0x43ca47ef,                                      \
-  0xebc8,                                          \
-  0x47a2,                                          \
-  {0x96, 0x79, 0xa4, 0x70, 0x32, 0x18, 0x08, 0x9f} \
-}
-static const nsID kDConnectTargetID = DCONNECT_IPC_TARGETID;
-
-//-----------------------------------------------------------------------------
-
-#define DCON_WAIT_TIMEOUT PR_INTERVAL_NO_TIMEOUT
-
-// used elsewhere like nsAtomTable to safely represent the integral value
-// of an address.
-typedef unsigned long PtrBits;
-
-//-----------------------------------------------------------------------------
-
-//
-// +--------------------------------+
-// | opcode : 1 byte                |
-// +--------------------------------+
-// | flags  : 1 byte                |
-// +--------------------------------+
-// .                                .
-// . variable payload               .
-// .                                .
-// +--------------------------------+
-//
-
-// dconnect major opcodes
-#define DCON_OP_SETUP   1
-#define DCON_OP_RELEASE 2
-#define DCON_OP_INVOKE  3
-
-#define DCON_OP_SETUP_REPLY  4
-#define DCON_OP_INVOKE_REPLY 5
-
-// dconnect minor opcodes for DCON_OP_SETUP
-#define DCON_OP_SETUP_NEW_INST_CLASSID    1
-#define DCON_OP_SETUP_NEW_INST_CONTRACTID 2
-#define DCON_OP_SETUP_GET_SERV_CLASSID    3
-#define DCON_OP_SETUP_GET_SERV_CONTRACTID 4
-#define DCON_OP_SETUP_QUERY_INTERFACE     5
-
-// dconnect minor opcodes for RELEASE
-// dconnect minor opcodes for INVOKE
-
-struct DConnectOp
-{
-  PRUint8  opcode_major;
-  PRUint8  opcode_minor;
-  PRUint32 request_index; // initialized with NewRequestIndex
-};
-
-typedef class DConnectInstance* DConAddr;
-
-// SETUP structs
-
-struct DConnectSetup : DConnectOp
-{
-  nsID iid;
-};
-
-struct DConnectSetupClassID : DConnectSetup
-{
-  nsID classid;
-};
-
-struct DConnectSetupContractID : DConnectSetup
-{
-  char contractid[1]; // variable length
-};
-
-struct DConnectSetupQueryInterface : DConnectSetup
-{
-  DConAddr instance;
-};
-
-// SETUP_REPLY struct
-
-struct DConnectSetupReply : DConnectOp
-{
-  DConAddr instance;
-  nsresult status;
-};
-
-// RELEASE struct
-
-struct DConnectRelease : DConnectOp
-{
-  DConAddr instance;
-};
-
-// INVOKE struct
-
-struct DConnectInvoke : DConnectOp
-{
-  DConAddr instance;
-  PRUint16 method_index;
-  // followed by an array of in-param blobs
-};
-
-// INVOKE_REPLY struct
-
-struct DConnectInvokeReply : DConnectOp
-{
-  nsresult result;
-  // followed by an array of out-param blobs
-};
-
-//-----------------------------------------------------------------------------
-
-static ipcDConnectService *gDConnect;
-
-//-----------------------------------------------------------------------------
-
-static nsresult
-SetupPeerInstance(PRUint32 aPeerID, DConnectSetup *aMsg, PRUint32 aMsgLen,
-                  void **aInstancePtr);
-
-//-----------------------------------------------------------------------------
-
-// A wrapper class holding an instance to an in-process XPCOM object.
-
-class DConnectInstance
-{
-public:
-  DConnectInstance(PRUint32 peer, nsIInterfaceInfo *iinfo, nsISupports *instance)
-    : mPeer(peer)
-    , mIInfo(iinfo)
-    , mInstance(instance)
-  {}
-
-  nsISupports      *RealInstance()  { return mInstance; }
-  nsIInterfaceInfo *InterfaceInfo() { return mIInfo; }
-  
-private:
-  PRUint32                   mPeer;  // peer process "owning" this instance
-  nsCOMPtr<nsIInterfaceInfo> mIInfo;
-  nsCOMPtr<nsISupports>      mInstance;
-};
-
-static void
-DeleteWrappers(nsVoidArray &wrappers)
-{
-  for (PRInt32 i=0; i<wrappers.Count(); ++i)
-    gDConnect->DeleteInstance((DConnectInstance *) wrappers[i]);
-}
-
-//-----------------------------------------------------------------------------
-
-static nsresult
-SerializeParam(ipcMessageWriter &writer, const nsXPTType &t, const nsXPTCMiniVariant &v)
-{
-  switch (t.TagPart())
-  {
-    case nsXPTType::T_I8:
-    case nsXPTType::T_U8:
-      writer.PutInt8(v.val.u8);
-      break;
-
-    case nsXPTType::T_I16:
-    case nsXPTType::T_U16:
-      writer.PutInt16(v.val.u16);
-      break;
-
-    case nsXPTType::T_I32:
-    case nsXPTType::T_U32:
-      writer.PutInt32(v.val.u32);
-      break;
-
-    case nsXPTType::T_I64:
-    case nsXPTType::T_U64:
-      writer.PutBytes(&v.val.u64, sizeof(PRUint64));
-      break;
-
-    case nsXPTType::T_FLOAT:
-      writer.PutBytes(&v.val.f, sizeof(float));
-      break;
-
-    case nsXPTType::T_DOUBLE:
-      writer.PutBytes(&v.val.d, sizeof(double));
-      break;
-
-    case nsXPTType::T_BOOL:
-      writer.PutBytes(&v.val.b, sizeof(PRBool));
-      break;
-
-    case nsXPTType::T_CHAR:
-      writer.PutBytes(&v.val.c, sizeof(char));
-      break;
-
-    case nsXPTType::T_WCHAR:
-      writer.PutBytes(&v.val.wc, sizeof(PRUnichar));
-      break;
-
-    case nsXPTType::T_IID:
-      writer.PutBytes(v.val.p, sizeof(nsID));
-      break;
-
-    case nsXPTType::T_CHAR_STR:
-      {
-        int len = strlen((const char *) v.val.p);
-        writer.PutInt32(len);
-        writer.PutBytes(v.val.p, len);
-      }
-      break;
-
-    case nsXPTType::T_WCHAR_STR:
-      {
-        int len = 2 * nsCRT::strlen((const PRUnichar *) v.val.p);
-        writer.PutInt32(len);
-        writer.PutBytes(v.val.p, len);
-      }
-      break;
-
-    case nsXPTType::T_INTERFACE:
-    case nsXPTType::T_INTERFACE_IS:
-      NS_NOTREACHED("this should be handled elsewhere");
-      return NS_ERROR_UNEXPECTED;
-
-    case nsXPTType::T_ASTRING:
-    case nsXPTType::T_DOMSTRING:
-      {
-        const nsAString *str = (const nsAString *) v.val.p;
-
-        PRUint32 len = 2 * str->Length();
-        nsAString::const_iterator begin;
-        const PRUnichar *data = str->BeginReading(begin).get();
-
-        writer.PutInt32(len);
-        writer.PutBytes(data, len);
-      }
-      break;
-
-    case nsXPTType::T_UTF8STRING:
-    case nsXPTType::T_CSTRING:
-      {
-        const nsACString *str = (const nsACString *) v.val.p;
-
-        PRUint32 len = str->Length();
-        nsACString::const_iterator begin;
-        const char *data = str->BeginReading(begin).get();
-
-        writer.PutInt32(len);
-        writer.PutBytes(data, len);
-      }
-      break;
-
-    case nsXPTType::T_ARRAY:
-      LOG(("array types are not yet supported\n"));
-      return NS_ERROR_NOT_IMPLEMENTED;
-
-    case nsXPTType::T_VOID:
-    case nsXPTType::T_PSTRING_SIZE_IS:
-    case nsXPTType::T_PWSTRING_SIZE_IS:
-    default:
-      LOG(("unexpected parameter type\n"));
-      return NS_ERROR_UNEXPECTED;
-  }
-  return NS_OK;
-}
-
-static nsresult
-DeserializeParam(ipcMessageReader &reader, const nsXPTType &t, nsXPTCVariant &v)
-{
-  // defaults
-  v.ptr = nsnull;
-  v.type = t;
-  v.flags = 0;
-
-  switch (t.TagPart())
-  {
-    case nsXPTType::T_I8:
-    case nsXPTType::T_U8:
-      v.val.u8 = reader.GetInt8();
-      break;
-
-    case nsXPTType::T_I16:
-    case nsXPTType::T_U16:
-      v.val.u16 = reader.GetInt16();
-      break;
-
-    case nsXPTType::T_I32:
-    case nsXPTType::T_U32:
-      v.val.u32 = reader.GetInt32();
-      break;
-
-    case nsXPTType::T_I64:
-    case nsXPTType::T_U64:
-      reader.GetBytes(&v.val.u64, sizeof(v.val.u64));
-      break;
-
-    case nsXPTType::T_FLOAT:
-      reader.GetBytes(&v.val.f, sizeof(v.val.f));
-      break;
-
-    case nsXPTType::T_DOUBLE:
-      reader.GetBytes(&v.val.d, sizeof(v.val.d));
-      break;
-
-    case nsXPTType::T_BOOL:
-      reader.GetBytes(&v.val.b, sizeof(v.val.b));
-      break;
-
-    case nsXPTType::T_CHAR:
-      reader.GetBytes(&v.val.c, sizeof(v.val.c));
-      break;
-
-    case nsXPTType::T_WCHAR:
-      reader.GetBytes(&v.val.wc, sizeof(v.val.wc));
-      break;
-
-    case nsXPTType::T_IID:
-      {
-        nsID *buf = (nsID *) malloc(sizeof(nsID));
-        NS_ENSURE_TRUE(buf, NS_ERROR_OUT_OF_MEMORY);
-        reader.GetBytes(buf, sizeof(nsID));
-        v.val.p = v.ptr = buf;
-        v.flags = nsXPTCVariant::PTR_IS_DATA | nsXPTCVariant::VAL_IS_ALLOCD;
-      }
-      break;
-
-    case nsXPTType::T_CHAR_STR:
-      {
-        PRUint32 len = reader.GetInt32();
-        char *buf = (char *) malloc(len + 1);
-        NS_ENSURE_TRUE(buf, NS_ERROR_OUT_OF_MEMORY);
-        reader.GetBytes(buf, len);
-        buf[len] = char(0);
-
-        v.val.p = v.ptr = buf;
-        v.flags = nsXPTCVariant::PTR_IS_DATA | nsXPTCVariant::VAL_IS_ALLOCD;
-      }
-      break;
-
-    case nsXPTType::T_WCHAR_STR:
-      {
-        PRUint32 len = reader.GetInt32();
-        PRUnichar *buf = (PRUnichar *) malloc(len + 2);
-        NS_ENSURE_TRUE(buf, NS_ERROR_OUT_OF_MEMORY);
-        reader.GetBytes(buf, len);
-        buf[len] = PRUnichar(0);
-
-        v.val.p = v.ptr = buf;
-        v.flags = nsXPTCVariant::PTR_IS_DATA | nsXPTCVariant::VAL_IS_ALLOCD;
-      }
-      break;
-
-    case nsXPTType::T_INTERFACE:
-    case nsXPTType::T_INTERFACE_IS:
-      {
-        reader.GetBytes(&v.ptr, sizeof(void *));
-        v.val.p = nsnull;
-        v.flags = nsXPTCVariant::PTR_IS_DATA;
-      }
-      break;
-
-    case nsXPTType::T_ASTRING:
-    case nsXPTType::T_DOMSTRING:
-      {
-        PRUint32 len = reader.GetInt32();
-
-        nsString *str = new nsString();
-        if (!str || !(EnsureStringLength(*str, len/2)))
-          return NS_ERROR_OUT_OF_MEMORY;
-        PRUnichar *buf = str->BeginWriting();
-        reader.GetBytes(buf, len);
-
-        v.val.p = v.ptr = str;
-        v.flags = nsXPTCVariant::PTR_IS_DATA | nsXPTCVariant::VAL_IS_DOMSTR;
-      }
-      break;
-
-    case nsXPTType::T_UTF8STRING:
-    case nsXPTType::T_CSTRING:
-      {
-        PRUint32 len = reader.GetInt32();
-
-        nsCString *str = new nsCString();
-        if (!str || !(EnsureStringLength(*str, len)))
-          return NS_ERROR_OUT_OF_MEMORY;
-        char *buf = str->BeginWriting();
-        reader.GetBytes(buf, len);
-
-        v.val.p = v.ptr = str;
-        v.flags = nsXPTCVariant::PTR_IS_DATA;
-
-        // this distinction here is pretty pointless
-        if (t.TagPart() == nsXPTType::T_CSTRING)
-          v.flags |= nsXPTCVariant::VAL_IS_CSTR;
-        else
-          v.flags |= nsXPTCVariant::VAL_IS_UTF8STR;
-      }
-      break;
-
-    case nsXPTType::T_ARRAY:
-      LOG(("array types are not yet supported\n"));
-      return NS_ERROR_NOT_IMPLEMENTED;
-
-    case nsXPTType::T_VOID:
-    case nsXPTType::T_PSTRING_SIZE_IS:
-    case nsXPTType::T_PWSTRING_SIZE_IS:
-    default:
-      LOG(("unexpected parameter type\n"));
-      return NS_ERROR_UNEXPECTED;
-  }
-  return NS_OK;
-}
-
-static nsresult
-SetupParam(const nsXPTParamInfo &p, nsXPTCVariant &v)
-{
-  const nsXPTType &t = p.GetType();
-
-  if (p.IsIn() && p.IsDipper())
-  {
-    v.ptr = nsnull;
-
-    switch (t.TagPart())
-    {
-      case nsXPTType::T_ASTRING:
-      case nsXPTType::T_DOMSTRING:
-        v.ptr = new nsString();
-        if (!v.ptr)
-          return NS_ERROR_OUT_OF_MEMORY;
-        v.val.p = v.ptr;
-        v.type = t;
-        v.flags = nsXPTCVariant::PTR_IS_DATA | nsXPTCVariant::VAL_IS_DOMSTR;
-        break;
-
-      case nsXPTType::T_UTF8STRING:
-      case nsXPTType::T_CSTRING:
-        v.ptr = new nsCString();
-        if (!v.ptr)
-          return NS_ERROR_OUT_OF_MEMORY;
-        v.val.p = v.ptr;
-        v.type = t;
-        v.flags = nsXPTCVariant::PTR_IS_DATA | nsXPTCVariant::VAL_IS_CSTR;
-        break;
-
-      default:
-        LOG(("unhandled dipper: type=%d\n", t.TagPart()));
-        return NS_ERROR_UNEXPECTED;
-    }
-  }
-  else if (p.IsOut())
-  {
-    v.ptr = &v.val;
-    v.type = t;
-    v.flags = nsXPTCVariant::PTR_IS_DATA;
-  }
-
-  return NS_OK;
-}
-
-static void
-FinishParam(nsXPTCVariant &v)
-{
-  if (!v.val.p)
-    return;
-
-  if (v.IsValAllocated())
-    free(v.val.p);
-  else if (v.IsValInterface())
-    ((nsISupports *) v.val.p)->Release();
-  else if (v.IsValDOMString())
-    delete (nsAString *) v.val.p;
-  else if (v.IsValUTF8String() || v.IsValCString())
-    delete (nsACString *) v.val.p;
-}
-
-static nsresult
-DeserializeResult(ipcMessageReader &reader, const nsXPTType &t, nsXPTCMiniVariant &v)
-{
-  if (v.val.p == nsnull)
-    return NS_OK;
-
-  switch (t.TagPart())
-  {
-    case nsXPTType::T_I8:
-    case nsXPTType::T_U8:
-      *((PRUint8 *) v.val.p) = reader.GetInt8();
-      break;
-
-    case nsXPTType::T_I16:
-    case nsXPTType::T_U16:
-      *((PRUint16 *) v.val.p) = reader.GetInt16();
-      break;
-
-    case nsXPTType::T_I32:
-    case nsXPTType::T_U32:
-      *((PRUint32 *) v.val.p) = reader.GetInt32();
-      break;
-
-    case nsXPTType::T_I64:
-    case nsXPTType::T_U64:
-      reader.GetBytes(v.val.p, sizeof(PRUint64));
-      break;
-
-    case nsXPTType::T_FLOAT:
-      reader.GetBytes(v.val.p, sizeof(float));
-      break;
-
-    case nsXPTType::T_DOUBLE:
-      reader.GetBytes(v.val.p, sizeof(double));
-      break;
-
-    case nsXPTType::T_BOOL:
-      reader.GetBytes(v.val.p, sizeof(PRBool));
-      break;
-
-    case nsXPTType::T_CHAR:
-      reader.GetBytes(v.val.p, sizeof(char));
-      break;
-
-    case nsXPTType::T_WCHAR:
-      reader.GetBytes(v.val.p, sizeof(PRUnichar));
-      break;
-
-    case nsXPTType::T_IID:
-      {
-        nsID *buf = (nsID *) nsMemory::Alloc(sizeof(nsID));
-        reader.GetBytes(buf, sizeof(nsID));
-        *((nsID **) v.val.p) = buf;
-      }
-      break;
-
-    case nsXPTType::T_CHAR_STR:
-      {
-        PRUint32 len = reader.GetInt32();
-        char *buf = (char *) nsMemory::Alloc(len + 1);
-        reader.GetBytes(buf, len);
-        buf[len] = char(0);
-
-        *((char **) v.val.p) = buf;
-      }
-      break;
-
-    case nsXPTType::T_WCHAR_STR:
-      {
-        PRUint32 len = reader.GetInt32();
-        PRUnichar *buf = (PRUnichar *) nsMemory::Alloc(len + 2);
-        reader.GetBytes(buf, len);
-        buf[len] = PRUnichar(0);
-
-        *((PRUnichar **) v.val.p) = buf;
-      }
-      break;
-
-    case nsXPTType::T_INTERFACE:
-    case nsXPTType::T_INTERFACE_IS:
-      {
-        // stub creation will be handled outside this routine.  we only
-        // deserialize the DConAddr into v.val.p temporarily.
-        void *ptr;
-        reader.GetBytes(&ptr, sizeof(void *));
-        *((void **) v.val.p) = ptr;
-      }
-      break;
-
-    case nsXPTType::T_ASTRING:
-    case nsXPTType::T_DOMSTRING:
-      {
-        PRUint32 len = reader.GetInt32();
-
-        nsAString *str = (nsAString *) v.val.p;
-
-        if (!str || !(EnsureStringLength(*str, len/2)))
-          return NS_ERROR_OUT_OF_MEMORY;
-        nsAString::iterator begin;
-        str->BeginWriting(begin);
-
-        reader.GetBytes(begin.get(), len);
-      }
-      break;
-
-    case nsXPTType::T_UTF8STRING:
-    case nsXPTType::T_CSTRING:
-      {
-        PRUint32 len = reader.GetInt32();
-
-        nsACString *str = (nsACString *) v.val.p;
-
-        if (!str || !(EnsureStringLength(*str, len)))
-          return NS_ERROR_OUT_OF_MEMORY;
-        nsACString::iterator begin;
-        str->BeginWriting(begin);
-
-        reader.GetBytes(begin.get(), len);
-      }
-      break;
-
-    case nsXPTType::T_ARRAY:
-      LOG(("array types are not yet supported\n"));
-      return NS_ERROR_NOT_IMPLEMENTED;
-
-    case nsXPTType::T_VOID:
-    case nsXPTType::T_PSTRING_SIZE_IS:
-    case nsXPTType::T_PWSTRING_SIZE_IS:
-    default:
-      LOG(("unexpected parameter type\n"));
-      return NS_ERROR_UNEXPECTED;
-  }
-  return NS_OK;
-}
-
-//-----------------------------------------------------------------------------
-
-static PRUint32
-NewRequestIndex()
-{
-  static PRUint32 sRequestIndex;
-  return ++sRequestIndex;
-}
-
-//-----------------------------------------------------------------------------
-
-class DConnectCompletion : public ipcIMessageObserver
-{
-public:
-  DConnectCompletion(PRUint32 requestIndex)
-    : mRequestIndex(requestIndex)
-  {}
-
-  // stack based only
-  NS_IMETHOD_(nsrefcnt) AddRef() { return 1; }
-  NS_IMETHOD_(nsrefcnt) Release() { return 1; }
-
-  NS_IMETHOD QueryInterface(const nsIID &aIID, void **aInstancePtr);
-
-  NS_IMETHOD OnMessageAvailable(PRUint32 aSenderID, const nsID &aTarget,
-                                const PRUint8 *aData, PRUint32 aDataLen)
-  {
-    const DConnectOp *op = (const DConnectOp *) aData;
-    if ((aDataLen >= sizeof(DConnectOp)) && (op->request_index == mRequestIndex))
-      OnResponseAvailable(aSenderID, op, aDataLen);
-    else
-      gDConnect->OnMessageAvailable(aSenderID, aTarget, aData, aDataLen);
-    return NS_OK;
-  }
-
-  virtual void OnResponseAvailable(PRUint32 sender, const DConnectOp *op, PRUint32 opLen) = 0;
-
-protected:
-  PRUint32 mRequestIndex;
-};
-NS_IMPL_QUERY_INTERFACE1(DConnectCompletion, ipcIMessageObserver)
-
-//-----------------------------------------------------------------------------
-
-class DConnectInvokeCompletion : public DConnectCompletion
-{
-public:
-  DConnectInvokeCompletion(const DConnectInvoke *invoke)
-    : DConnectCompletion(invoke->request_index)
-    , mReply(nsnull)
-    , mParamsLen(0)
-  {}
-
-  ~DConnectInvokeCompletion() { if (mReply) free(mReply); }
-
-  void OnResponseAvailable(PRUint32 sender, const DConnectOp *op, PRUint32 opLen)
-  {
-    mReply = (DConnectInvokeReply *) malloc(opLen);
-    if (!mReply)
-      return; // out of memory
-    memcpy(mReply, op, opLen);
-
-    // the length in bytes of the parameter blob
-    mParamsLen = opLen - sizeof(*mReply);
-  }
-
-  PRBool IsPending() const { return mReply == nsnull; }
-  nsresult GetResult() const { return mReply->result; }
-
-  const PRUint8 *Params() const { return (const PRUint8 *) (mReply + 1); }
-  PRUint32 ParamsLen() const { return mParamsLen; }
-
-  const DConnectInvokeReply *Reply() const { return mReply; }
-
-private:
-  DConnectInvokeReply *mReply;
-  PRUint32             mParamsLen;
-};
-
-//-----------------------------------------------------------------------------
-
-#define DCONNECT_STUB_ID                           \
-{ /* 132c1f14-5442-49cb-8fe6-e60214bbf1db */       \
-  0x132c1f14,                                      \
-  0x5442,                                          \
-  0x49cb,                                          \
-  {0x8f, 0xe6, 0xe6, 0x02, 0x14, 0xbb, 0xf1, 0xdb} \
-}
-static NS_DEFINE_IID(kDConnectStubID, DCONNECT_STUB_ID);
-
-// this class represents the non-local object instance.
-
-class DConnectStub : public nsXPTCStubBase
-{
-public:
-  NS_DECL_ISUPPORTS
-
-  DConnectStub(nsIInterfaceInfo *aIInfo,
-               DConAddr aInstance,
-               PRUint32 aPeerID)
-    : mIInfo(aIInfo)
-    , mMaster(nsnull)
-    , mInstance(aInstance)
-    , mPeerID(aPeerID)
-    {}
-
-  // return a refcounted pointer to the InterfaceInfo for this object
-  // NOTE: on some platforms this MUST not fail or we crash!
-  NS_IMETHOD GetInterfaceInfo(nsIInterfaceInfo **aInfo);
-
-  // call this method and return result
-  NS_IMETHOD CallMethod(PRUint16 aMethodIndex,
-                        const nsXPTMethodInfo *aInfo,
-                        nsXPTCMiniVariant *aParams);
-
-  DConAddr Instance() { return mInstance; }
-  PRUint32 PeerID()   { return mPeerID; }
-
-private:
-  NS_HIDDEN ~DConnectStub();
-
-  // returns a weak reference to a child supporting the specified interface
-  NS_HIDDEN_(DConnectStub *) FindStubSupportingIID(const nsID &aIID);
-
-  // returns true if this stub supports the specified interface
-  NS_HIDDEN_(PRBool) SupportsIID(const nsID &aIID);
-
-private:
-  nsCOMPtr<nsIInterfaceInfo> mIInfo;
-
-  nsVoidArray   mChildren; // weak references (cleared by the children)
-  DConnectStub *mMaster;   // strong reference
-
-  // uniquely identifies this object instance between peers.
-  DConAddr mInstance;
-
-  // the "client id" of our IPC peer.  this guy owns the real object.
-  PRUint32 mPeerID;
-};
-
-static nsresult
-CreateStub(const nsID &iid, PRUint32 peer, DConAddr instance, DConnectStub **result)
-{
-  nsresult rv;
-
-  nsCOMPtr<nsIInterfaceInfo> iinfo;
-  rv = gDConnect->GetInterfaceInfo(iid, getter_AddRefs(iinfo));
-  if (NS_FAILED(rv))
-    return rv;
-
-  DConnectStub *stub = new DConnectStub(iinfo,
-                                        instance,
-                                        peer);
-  if (NS_UNLIKELY(!stub))
-    rv = NS_ERROR_OUT_OF_MEMORY;
-  else
-  {
-    NS_ADDREF(stub);
-    *result = stub;
-  }
-
-  return rv;
-}
-
-static nsresult
-SerializeInterfaceParam(ipcMessageWriter &writer,
-                        PRUint32 peer, const nsID &iid,
-                        const nsXPTType &type, const nsXPTCMiniVariant &v,
-                        nsVoidArray &wrappers)
-{
-  // we create an instance wrapper, and assume that the other side will send a
-  // RELEASE message when it no longer needs the instance wrapper.  that will
-  // usually happen after the call returns.
-  //
-  // XXX a lazy scheme might be better, but for now simplicity wins.
-
-  // if the interface pointer references a DConnectStub corresponding
-  // to an object in the address space of the peer, then no need to
-  // create a new wrapper.
-
-  nsISupports *obj = (nsISupports *) v.val.p;
-  if (!obj)
-  {
-    // write null address
-    writer.PutBytes(&obj, sizeof(obj));
-  }
-  else
-  {
-    DConnectStub *stub = nsnull;
-    nsresult rv = obj->QueryInterface(kDConnectStubID, (void **) &stub);
-    if (NS_SUCCEEDED(rv) && (stub->PeerID() == peer))
-    {
-      void *p = stub->Instance();
-      writer.PutBytes(&p, sizeof(p));
-    }
-    else
-    {
-      // create instance wrapper
-
-      nsCOMPtr<nsIInterfaceInfo> iinfo;
-      rv = gDConnect->GetInterfaceInfo(iid, getter_AddRefs(iinfo));
-      if (NS_FAILED(rv))
-        return rv;
-
-      DConnectInstance *wrapper = nsnull;
-
-      wrapper = new DConnectInstance(peer, iinfo, obj);
-      if (!wrapper)
-        return NS_ERROR_OUT_OF_MEMORY;
-
-      if (!wrappers.AppendElement(wrapper))
-      {
-        delete wrapper;
-        return NS_ERROR_OUT_OF_MEMORY;
-      }
-
-      rv = gDConnect->StoreInstance(wrapper);
-      if (NS_FAILED(rv))
-      {
-        wrappers.RemoveElement(wrapper);
-        delete wrapper;
-        return rv;
-      }
-
-      // send address of the instance wrapper, and set the low bit
-      // to indicate that this is an instance wrapper.
-      PtrBits bits = ((PtrBits) wrapper) | 0x1;
-      writer.PutBytes(&bits, sizeof(bits));
-    }
-    NS_IF_RELEASE(stub);
-  }
-  return NS_OK;
-}
-
-DConnectStub::~DConnectStub()
-{
-  // destroying stub, notify peer that we have released our reference
-
-  nsresult rv;
-
-  DConnectRelease msg;
-  msg.opcode_major = DCON_OP_RELEASE;
-  msg.opcode_minor = 0;
-  msg.instance = mInstance;
-
-  // fire off asynchronously... we don't expect any response to this message.
-  rv = IPC_SendMessage(mPeerID, kDConnectTargetID,
-                       (const PRUint8 *) &msg, sizeof(msg));
-  if (NS_FAILED(rv))
-    NS_WARNING("failed to send RELEASE event");
-
-  if (!mMaster)
-  {
-    // delete each child stub
-    for (PRInt32 i=0; i<mChildren.Count(); ++i)
-      delete (DConnectStub *) mChildren[i];
-  }
-}
-
-PRBool
-DConnectStub::SupportsIID(const nsID &iid)
-{
-  PRBool match;
-  nsCOMPtr<nsIInterfaceInfo> iter = mIInfo;
-  do
-  {
-    if (NS_SUCCEEDED(iter->IsIID(&iid, &match)) && match)
-      return PR_TRUE;
-
-    nsCOMPtr<nsIInterfaceInfo> parent;
-    iter->GetParent(getter_AddRefs(parent));
-    iter = parent;
-  }
-  while (iter != nsnull);
-
-  return PR_FALSE;
-}
-
-DConnectStub *
-DConnectStub::FindStubSupportingIID(const nsID &iid)
-{
-  NS_ASSERTION(mMaster == nsnull, "this is not a master stub");
-
-  if (SupportsIID(iid))
-    return this;
-
-  for (PRInt32 i=0; i<mChildren.Count(); ++i)
-  {
-    DConnectStub *child = (DConnectStub *) mChildren[i];
-    if (child->SupportsIID(iid))
-      return child;
-  }
-  return nsnull;
-}
-
-NS_IMETHODIMP_(nsrefcnt)
-DConnectStub::AddRef()
-{
-  if (mMaster)
-    return mMaster->AddRef();
-
-  NS_ASSERT_OWNINGTHREAD("DConnectStub");
-  ++mRefCnt;
-  NS_LOG_ADDREF(this, mRefCnt, "DConnectStub", sizeof(*this));
-  return mRefCnt;
-}
-
-NS_IMETHODIMP_(nsrefcnt)
-DConnectStub::Release()
-{
-  if (mMaster)
-    return mMaster->Release();
-
-  NS_ASSERT_OWNINGTHREAD("DConnectStub");
-  --mRefCnt;
-  NS_LOG_RELEASE(this, mRefCnt, "DConnectStub");
-  if (mRefCnt == 0)
-  {
-    mRefCnt = 1; /* stabilize */
-    delete this;
-    return 0;
-  }                                                                           \
-  return mRefCnt;        
-}
-
-NS_IMETHODIMP
-DConnectStub::QueryInterface(const nsID &aIID, void **aInstancePtr)
-{
-  DConnectStub *master = mMaster ? mMaster : this;
-
-  // always return the master stub for nsISupports
-  if (aIID.Equals(NS_GET_IID(nsISupports)))
-  {
-    *aInstancePtr = master;
-    NS_ADDREF(master);
-    return NS_OK;
-  }
-
-  // used to discover if this is a DConnectStub instance.
-  if (aIID.Equals(kDConnectStubID))
-  {
-    *aInstancePtr = this;
-    NS_ADDREF_THIS();
-    return NS_OK;
-  }
-
-  // it might seem attractive to check this stub first for parent
-  // interfaces, but we should instead always defer to the master
-  // since that ensures that the result of QI is independent of
-  // the stub on which it is called.
-#if 0
-  if (SupportsIID(aIID))
-  {
-    *aInstancePtr = this;
-    NS_ADDREF(this);
-    return NS_OK;
-  }
-#endif
-
-  // does any existing stub support the requested IID?
-  DConnectStub *stub = master->FindStubSupportingIID(aIID);
-  if (stub)
-  {
-    *aInstancePtr = stub;
-    NS_ADDREF(stub);
-    return NS_OK;
-  }
-
-  // else, we need to query the peer object
-  LOG(("calling QueryInterface on peer object\n"));
-
-  DConnectSetupQueryInterface msg;
-  msg.opcode_minor = DCON_OP_SETUP_QUERY_INTERFACE;
-  msg.iid = aIID;
-  msg.instance = mInstance;
-
-  void *result;
-
-  nsresult rv = SetupPeerInstance(mPeerID, &msg, sizeof(msg), &result);
-  if (NS_FAILED(rv))
-    return rv;
-
-  stub = (DConnectStub *) result;
-
-  // add stub to the master's list of children, so we can preserve
-  // symmetry in future QI calls.  the master will delete each child
-  // when it is destroyed.  the refcount of each child is bound to
-  // the refcount of the master.  this is done to deal with code
-  // like this:
-  //
-  //   nsCOMPtr<nsIBar> bar = ...;
-  //   nsIFoo *foo;
-  //   {
-  //     nsCOMPtr<nsIFoo> temp = do_QueryInterface(bar);
-  //     foo = temp;
-  //   }
-  //   foo->DoStuff();
-  //
-  // while this code is not valid XPCOM (since it is using |foo|
-  // after having called Release on it), such code is unfortunately
-  // very common in the mozilla codebase.  the assumption this code
-  // is making is that so long as |bar| is alive, it should be valid
-  // to access |foo| even if the code doesn't own a strong reference
-  // to |foo|!  clearly wrong, but we need to support it anyways.
-
-  stub->mMaster = master;
-  master->mChildren.AppendElement(stub);
-
-  *aInstancePtr = stub;
-  NS_ADDREF(stub);
-  return NS_OK;
-}
-
-NS_IMETHODIMP
-DConnectStub::GetInterfaceInfo(nsIInterfaceInfo **aInfo)
-{
-  NS_ADDREF(*aInfo = mIInfo);
-  return NS_OK;
-}
-
-NS_IMETHODIMP
-DConnectStub::CallMethod(PRUint16 aMethodIndex,
-                         const nsXPTMethodInfo *aInfo,
-                         nsXPTCMiniVariant *aParams)
-{
-  nsresult rv;
-
-  LOG(("DConnectStub::CallMethod [methodIndex=%hu]\n", aMethodIndex));
-
-  // dump arguments
-
-  PRUint8 i, paramCount = aInfo->GetParamCount();
-
-  LOG(("  name=%s\n", aInfo->GetName()));
-  LOG(("  param-count=%u\n", (PRUint32) paramCount));
-
-  ipcMessageWriter writer(16 * paramCount);
-
-  // INVOKE message header
-  DConnectInvoke invoke;
-  invoke.opcode_major = DCON_OP_INVOKE;
-  invoke.opcode_minor = 0;
-  invoke.request_index = NewRequestIndex();
-  invoke.instance = mInstance;
-  invoke.method_index = aMethodIndex;
-
-  writer.PutBytes(&invoke, sizeof(invoke));
-
-  // list of wrappers that get created during parameter serialization.  if we
-  // are unable to send the INVOKE message, then we'll clean these up.
-  nsVoidArray wrappers;
-
-  for (i=0; i<paramCount; ++i)
-  {
-    const nsXPTParamInfo &paramInfo = aInfo->GetParam(i);
-
-    if (paramInfo.IsIn() && !paramInfo.IsDipper())
-    {
-      const nsXPTType &type = paramInfo.GetType();
-
-      if (type.IsInterfacePointer())
-      {
-        nsID iid;
-        rv = gDConnect->GetIIDForMethodParam(mIInfo, aInfo, paramInfo, type,
-                                             aMethodIndex, i, aParams, PR_FALSE, iid);
-        if (NS_SUCCEEDED(rv))
-          rv = SerializeInterfaceParam(writer, mPeerID, iid, type, aParams[i], wrappers);
-      }
-      else
-        rv = SerializeParam(writer, type, aParams[i]);
-
-      if (NS_FAILED(rv))
-        return rv;
-    }
-  }
-
-  rv = IPC_SendMessage(mPeerID, kDConnectTargetID,
-                       writer.GetBuffer(),
-                       writer.GetSize());
-  if (NS_FAILED(rv))
-  {
-    // INVOKE message wasn't delivered; clean up wrappers
-    DeleteWrappers(wrappers);
-    return rv;
-  }
-
-  // now, we wait for the method call to complete.  during that time, it's
-  // possible that we'll receive other method call requests.  we'll process
-  // those while waiting for out method call to complete.  it's critical that
-  // we do so since those other method calls might need to complete before
-  // out method call can complete!
-
-  DConnectInvokeCompletion completion(&invoke);
-
-  do
-  {
-    rv = IPC_WaitMessage(mPeerID, kDConnectTargetID, &completion,
-                         DCON_WAIT_TIMEOUT);
-    if (NS_FAILED(rv))
-    {
-      // INVOKE message wasn't received; clean up wrappers
-      DeleteWrappers(wrappers);
-      return rv;
-    }
-  }
-  while (completion.IsPending());
-
-  rv = completion.GetResult();
-  if (NS_SUCCEEDED(rv) && completion.ParamsLen() > 0)
-  {
-    ipcMessageReader reader(completion.Params(), completion.ParamsLen());
-
-    PRUint8 i;
-
-    // handle out-params and retvals: DCON_OP_INVOKE_REPLY has the data
-    for (i=0; i<paramCount; ++i)
-    {
-      const nsXPTParamInfo &paramInfo = aInfo->GetParam(i);
-
-      if (paramInfo.IsOut() || paramInfo.IsRetval())
-        DeserializeResult(reader, paramInfo.GetType(), aParams[i]);
-    }
-
-    // fixup any interface pointers using a second pass so we can properly
-    // handle INTERFACE_IS referencing an IID that is an out param!
-    for (i=0; i<paramCount; ++i)
-    {
-      const nsXPTParamInfo &paramInfo = aInfo->GetParam(i);
-      if (aParams[i].val.p && (paramInfo.IsOut() || paramInfo.IsRetval()))
-      {
-        const nsXPTType &type = paramInfo.GetType();
-        if (type.IsInterfacePointer())
-        {
-          PtrBits bits = (PtrBits) *((void **) aParams[i].val.p);
-          if (bits & 0x1)
-          {
-            *((void **) aParams[i].val.p) = (void *) (bits & ~0x1);
-
-            nsID iid;
-            rv = gDConnect->GetIIDForMethodParam(mIInfo, aInfo, paramInfo, type,
-                                                 aMethodIndex, i, aParams, PR_FALSE, iid);
-            if (NS_SUCCEEDED(rv))
-            {
-              DConnectStub *stub;
-              void **pptr = (void **) aParams[i].val.p;
-              rv = CreateStub(iid, mPeerID, (DConAddr) *pptr, &stub);
-              if (NS_SUCCEEDED(rv))
-                *((nsISupports **) aParams[i].val.p) = stub;
-            }
-          }
-          else if (bits)
-          {
-            // pointer is to one of our instance wrappers.
-
-            DConnectInstance *wrapper = (DConnectInstance *) aParams[i].val.p;
-            *((void **) aParams[i].val.p) = wrapper->RealInstance();
-          }
-          else
-          {
-            *((void **) aParams[i].val.p) = nsnull;
-          }
-        }
-      }
-    }
-  }
-
-  return rv;
-}
-
-//-----------------------------------------------------------------------------
-
-class DConnectSetupCompletion : public DConnectCompletion
-{
-public:
-  DConnectSetupCompletion(const DConnectSetup *setup)
-    : DConnectCompletion(setup->request_index)
-    , mSetup(setup)
-    , mStatus(NS_OK)
-  {}
-
-  void OnResponseAvailable(PRUint32 sender, const DConnectOp *op, PRUint32 opLen)
-  {
-    if (op->opcode_major != DCON_OP_SETUP_REPLY)
-    {
-      NS_NOTREACHED("unexpected response");
-      mStatus = NS_ERROR_UNEXPECTED;
-      return;
-    }
-
-    const DConnectSetupReply *reply = (const DConnectSetupReply *) op;
-
-    LOG(("got SETUP_REPLY: status=%x instance=%p\n", reply->status, reply->instance));
-
-    if (NS_FAILED(reply->status))
-    {
-      NS_ASSERTION(!reply->instance, "non-null instance on failure");
-      mStatus = reply->status;
-    }
-    else
-    {
-      nsresult rv = CreateStub(mSetup->iid, sender, reply->instance,
-                               getter_AddRefs(mStub));
-      if (NS_FAILED(rv))
-        mStatus = rv;
-    }
-  }
-
-  nsresult GetStub(void **aInstancePtr)
-  {
-    if (NS_FAILED(mStatus))
-      return mStatus;
-
-    DConnectStub *stub = mStub;
-    NS_IF_ADDREF(stub);
-    *aInstancePtr = stub;
-    return NS_OK;
-  }
-
-private:
-  const DConnectSetup    *mSetup;
-  nsresult                mStatus;
-  nsRefPtr<DConnectStub>  mStub;
-};
-
-// static
-nsresult
-SetupPeerInstance(PRUint32 aPeerID, DConnectSetup *aMsg, PRUint32 aMsgLen,
-                  void **aInstancePtr)
-{
-  *aInstancePtr = nsnull;
-
-  aMsg->opcode_major = DCON_OP_SETUP;
-  aMsg->request_index = NewRequestIndex();
-
-  // send SETUP message, expect SETUP_REPLY
-
-  nsresult rv = IPC_SendMessage(aPeerID, kDConnectTargetID,
-                                (const PRUint8 *) aMsg, aMsgLen);
-  if (NS_FAILED(rv))
-    return rv;
-
-  DConnectSetupCompletion completion(aMsg);
-
-  // need to allow messages from other clients to be processed immediately 
-  // to avoid distributed dead locks.  the completion's OnMessageAvailable
-  // will call our default OnMessageAvailable if it receives any message
-  // other than the one for which it is waiting.
-
-  do
-  {
-    rv = IPC_WaitMessage(aPeerID, kDConnectTargetID, &completion, DCON_WAIT_TIMEOUT);
-    if (NS_FAILED(rv))
-      break;
-
-    rv = completion.GetStub(aInstancePtr);
-  }
-  while (NS_SUCCEEDED(rv) && *aInstancePtr == nsnull);
-
-  return rv;
-} 
-
-//-----------------------------------------------------------------------------
-
-static PLDHashOperator
-DestroyDConnectInstance(const void *key,
-                        DConnectInstance *wrapper,
-                        void *userArg)
-{
-  delete wrapper;
-  return PL_DHASH_NEXT;
-}
-
-//-----------------------------------------------------------------------------
-
-ipcDConnectService::~ipcDConnectService()
-{
-  // make sure we have released all instances
-  mInstances.EnumerateRead(DestroyDConnectInstance, nsnull);
-  mInstances.Clear();
-
-  gDConnect = nsnull;
-}
-
-nsresult
-ipcDConnectService::Init()
-{
-  nsresult rv;
-
-  rv = IPC_DefineTarget(kDConnectTargetID, this);
-  if (NS_FAILED(rv))
-    return rv;
-
-  if (!mInstances.Init())
-    return NS_ERROR_OUT_OF_MEMORY;
-
-  mIIM = do_GetService(NS_INTERFACEINFOMANAGER_SERVICE_CONTRACTID, &rv);
-  if (NS_FAILED(rv))
-    return rv;
-
-  gDConnect = this;
-  return NS_OK;
-}
-
-// this should be inlined
-nsresult
-ipcDConnectService::GetInterfaceInfo(const nsID &iid, nsIInterfaceInfo **result)
-{
-  return mIIM->GetInfoForIID(&iid, result);
-}
-
-// this is adapted from the version in xpcwrappednative.cpp
-nsresult
-ipcDConnectService::GetIIDForMethodParam(nsIInterfaceInfo *iinfo,
-                                         const nsXPTMethodInfo *methodInfo,
-                                         const nsXPTParamInfo &paramInfo,
-                                         const nsXPTType &type,
-                                         PRUint16 methodIndex,
-                                         PRUint8 paramIndex,
-                                         nsXPTCMiniVariant *dispatchParams,
-                                         PRBool isFullVariantArray,
-                                         nsID &result)
-{
-  PRUint8 argnum, tag = type.TagPart();
-  nsresult rv;
-
-  if (tag == nsXPTType::T_INTERFACE)
-  {
-    rv = iinfo->GetIIDForParamNoAlloc(methodIndex, &paramInfo, &result);
-  }
-  else if (tag == nsXPTType::T_INTERFACE_IS)
-  {
-    rv = iinfo->GetInterfaceIsArgNumberForParam(methodIndex, &paramInfo, &argnum);
-    if (NS_FAILED(rv))
-      return rv;
-
-    const nsXPTParamInfo& arg_param = methodInfo->GetParam(argnum);
-    const nsXPTType& arg_type = arg_param.GetType();
-
-    // The xpidl compiler ensures this. We reaffirm it for safety.
-    if (!arg_type.IsPointer() || arg_type.TagPart() != nsXPTType::T_IID)
-      return NS_ERROR_UNEXPECTED;
-
-    nsID *p;
-    if (isFullVariantArray)
-      p = (nsID *) ((nsXPTCVariant *) dispatchParams)[argnum].val.p;
-    else
-      p = (nsID *) dispatchParams[argnum].val.p;
-    if (!p)
-      return NS_ERROR_UNEXPECTED;
-
-    result = *p;
-  }
-  else
-    rv = NS_ERROR_UNEXPECTED;
-  return rv;
-}
-
-nsresult
-ipcDConnectService::StoreInstance(DConnectInstance *wrapper)
-{
-  return mInstances.Put(nsVoidPtrHashKey(wrapper).GetKey(), wrapper)
-      ? NS_OK : NS_ERROR_OUT_OF_MEMORY;
-}
-
-void
-ipcDConnectService::DeleteInstance(DConnectInstance *wrapper)
-{
-  // this calls |operator delete|
-  mInstances.Remove(nsVoidPtrHashKey(wrapper).GetKey());
-}
-
-NS_IMPL_ISUPPORTS2(ipcDConnectService, ipcIDConnectService, ipcIMessageObserver)
-
-NS_IMETHODIMP
-ipcDConnectService::CreateInstance(PRUint32 aPeerID,
-                                   const nsID &aCID,
-                                   const nsID &aIID,
-                                   void **aInstancePtr)
-{
-  DConnectSetupClassID msg;
-  msg.opcode_minor = DCON_OP_SETUP_NEW_INST_CLASSID;
-  msg.iid = aIID;
-  msg.classid = aCID;
-
-  return SetupPeerInstance(aPeerID, &msg, sizeof(msg), aInstancePtr);
-}
-
-NS_IMETHODIMP
-ipcDConnectService::CreateInstanceByContractID(PRUint32 aPeerID,
-                                               const char *aContractID,
-                                               const nsID &aIID,
-                                               void **aInstancePtr)
-{
-  size_t slen = strlen(aContractID);
-  size_t size = sizeof(DConnectSetupContractID) + slen;
-
-  DConnectSetupContractID *msg =
-      (DConnectSetupContractID *) malloc(size);
-  NS_ENSURE_TRUE(msg, NS_ERROR_OUT_OF_MEMORY);
-
-  msg->opcode_minor = DCON_OP_SETUP_NEW_INST_CONTRACTID;
-  msg->iid = aIID;
-  memcpy(&msg->contractid, aContractID, slen + 1);
-
-  nsresult rv = SetupPeerInstance(aPeerID, msg, size, aInstancePtr);
-
-  free(msg);
-  return rv;
-}
-
-NS_IMETHODIMP
-ipcDConnectService::GetService(PRUint32 aPeerID,
-                               const nsID &aCID,
-                               const nsID &aIID,
-                               void **aInstancePtr)
-{
-  DConnectSetupClassID msg;
-  msg.opcode_minor = DCON_OP_SETUP_GET_SERV_CLASSID;
-  msg.iid = aIID;
-  msg.classid = aCID;
-
-  return SetupPeerInstance(aPeerID, &msg, sizeof(msg), aInstancePtr);
-}
-
-NS_IMETHODIMP
-ipcDConnectService::GetServiceByContractID(PRUint32 aPeerID,
-                                           const char *aContractID,
-                                           const nsID &aIID,
-                                           void **aInstancePtr)
-{
-  size_t slen = strlen(aContractID);
-  size_t size = sizeof(DConnectSetupContractID) + slen;
-
-  DConnectSetupContractID *msg =
-      (DConnectSetupContractID *) malloc(size);
-  NS_ENSURE_TRUE(msg, NS_ERROR_OUT_OF_MEMORY);
-
-  msg->opcode_minor = DCON_OP_SETUP_GET_SERV_CONTRACTID;
-  msg->iid = aIID;
-  memcpy(&msg->contractid, aContractID, slen + 1);
-
-  nsresult rv = SetupPeerInstance(aPeerID, msg, size, aInstancePtr);
-
-  free(msg);
-  return rv;
-}
-
-//-----------------------------------------------------------------------------
-
-NS_IMETHODIMP
-ipcDConnectService::OnMessageAvailable(PRUint32 aSenderID,
-                                       const nsID &aTarget,
-                                       const PRUint8 *aData,
-                                       PRUint32 aDataLen)
-{
-  const DConnectOp *op = (const DConnectOp *) aData;
-  switch (op->opcode_major)
-  {
-    case DCON_OP_SETUP:
-      OnSetup(aSenderID, (const DConnectSetup *) aData, aDataLen);
-      break;
-    case DCON_OP_RELEASE:
-      OnRelease(aSenderID, (const DConnectRelease *) aData);
-      break;
-    case DCON_OP_INVOKE:
-      OnInvoke(aSenderID, (const DConnectInvoke *) aData, aDataLen);
-      break;
-    default:
-      NS_NOTREACHED("unknown opcode major");
-  }
-
-  return NS_OK;
-}
-
-//-----------------------------------------------------------------------------
-
-void
-ipcDConnectService::OnSetup(PRUint32 peer, const DConnectSetup *setup, PRUint32 opLen)
-{
-  nsISupports *instance = nsnull;
-  nsresult rv = NS_ERROR_FAILURE;
-
-  switch (setup->opcode_minor)
-  {
-    // CreateInstance
-    case DCON_OP_SETUP_NEW_INST_CLASSID:
-    {
-      const DConnectSetupClassID *setupCI = (const DConnectSetupClassID *) setup;
-
-      nsCOMPtr<nsIComponentManager> compMgr;
-      rv = NS_GetComponentManager(getter_AddRefs(compMgr));
-      if (NS_SUCCEEDED(rv))
-        rv = compMgr->CreateInstance(setupCI->classid, nsnull, setupCI->iid, (void **) &instance);
-
-      break;
-    }
-
-    // CreateInstanceByContractID
-    case DCON_OP_SETUP_NEW_INST_CONTRACTID:
-    {
-      const DConnectSetupContractID *setupCI = (const DConnectSetupContractID *) setup;
-
-      nsCOMPtr<nsIComponentManager> compMgr;
-      rv = NS_GetComponentManager(getter_AddRefs(compMgr));
-      if (NS_SUCCEEDED(rv))
-        rv = compMgr->CreateInstanceByContractID(setupCI->contractid, nsnull, setupCI->iid, (void **) &instance);
-
-      break;
-    }
-
-    // GetService
-    case DCON_OP_SETUP_GET_SERV_CLASSID:
-    {
-      const DConnectSetupClassID *setupCI = (const DConnectSetupClassID *) setup;
-
-      nsCOMPtr<nsIServiceManager> svcMgr;
-      rv = NS_GetServiceManager(getter_AddRefs(svcMgr));
-      if (NS_SUCCEEDED(rv))
-        rv = svcMgr->GetService(setupCI->classid, setupCI->iid, (void **) &instance);
-      break;
-    }
-
-    // GetServiceByContractID
-    case DCON_OP_SETUP_GET_SERV_CONTRACTID:
-    {
-      const DConnectSetupContractID *setupCI = (const DConnectSetupContractID *) setup;
-
-      nsCOMPtr<nsIServiceManager> svcMgr;
-      rv = NS_GetServiceManager(getter_AddRefs(svcMgr));
-      if (NS_SUCCEEDED(rv))
-        rv = svcMgr->GetServiceByContractID(setupCI->contractid, setupCI->iid, (void **) &instance);
-
-      break;
-    }
-
-    // QueryInterface
-    case DCON_OP_SETUP_QUERY_INTERFACE:
-    {
-      const DConnectSetupQueryInterface *setupQI = (const DConnectSetupQueryInterface *) setup;
-  
-      // make sure we've been sent a valid wrapper
-      if (!mInstances.Get(nsVoidPtrHashKey(setupQI->instance).GetKey(), nsnull))
-      {
-        NS_NOTREACHED("instance wrapper not found");
-        rv = NS_ERROR_INVALID_ARG;
-      }
-      else
-        rv = setupQI->instance->RealInstance()->QueryInterface(setupQI->iid, (void **) &instance);
-      break;
-    }
-
-    default:
-      NS_NOTREACHED("unexpected minor opcode");
-      rv = NS_ERROR_UNEXPECTED;
-      break;
-  }
-
-  // now, create instance wrapper, and store it in our instances set.
-  // this allows us to keep track of object references held on behalf of a
-  // particular peer.  we can use this information to cleanup after a peer
-  // that disconnects without sending RELEASE messages for its objects.
-  DConnectInstance *wrapper = nsnull;
-  if (NS_SUCCEEDED(rv))
-  {
-    nsCOMPtr<nsIInterfaceInfo> iinfo;
-    rv = gDConnect->GetInterfaceInfo(setup->iid, getter_AddRefs(iinfo));
-    if (NS_SUCCEEDED(rv))
-    {
-      wrapper = new DConnectInstance(peer, iinfo, instance);
-      if (!wrapper)
-        rv = NS_ERROR_OUT_OF_MEMORY;
-      else
-        rv = StoreInstance(wrapper);
-    }
-  }
-
-  if (NS_FAILED(rv) && instance)
-    NS_RELEASE(instance);
-
-  DConnectSetupReply msg;
-  msg.opcode_major = DCON_OP_SETUP_REPLY;
-  msg.opcode_minor = 0;
-  msg.request_index = setup->request_index;
-  msg.instance = wrapper;
-  msg.status = rv;
-
-  // fire off SETUP_REPLY, don't wait for a response
-  IPC_SendMessage(peer, kDConnectTargetID,
-                  (const PRUint8 *) &msg, sizeof(msg));
-}
-
-void
-ipcDConnectService::OnRelease(PRUint32 peer, const DConnectRelease *release)
-{
-  LOG(("ipcDConnectService::OnRelease [peer=%u instance=%p]\n", peer, release->instance));
-
-#ifdef DEBUG
-  // make sure we've been sent a valid wrapper
-  if (!mInstances.Get(nsVoidPtrHashKey(release->instance).GetKey(), nsnull))
-    NS_NOTREACHED("instance wrapper not found");
-#endif
-
-  DeleteInstance(release->instance);
-}
-
-void
-ipcDConnectService::OnInvoke(PRUint32 peer, const DConnectInvoke *invoke, PRUint32 opLen)
-{
-  LOG(("ipcDConnectService::OnInvoke [peer=%u instance=%p method=%u]\n",
-      peer, invoke->instance, invoke->method_index));
-
-  DConnectInstance *wrapper = invoke->instance;
-
-  ipcMessageReader reader((const PRUint8 *) (invoke + 1), opLen - sizeof(*invoke));
-
-  const nsXPTMethodInfo *methodInfo;
-  nsXPTCVariant *params = nsnull;
-  nsIInterfaceInfo *iinfo = nsnull;
-  PRUint8 i, paramCount = 0, paramUsed = 0;
-  nsresult rv;
-  
-  // make sure we've been sent a valid wrapper
-  if (!mInstances.Get(nsVoidPtrHashKey(wrapper).GetKey(), nsnull))
-  {
-    NS_NOTREACHED("instance wrapper not found");
-    rv = NS_ERROR_INVALID_ARG;
-    goto end;
-  }
-
-  iinfo = wrapper->InterfaceInfo();
-
-  rv = iinfo->GetMethodInfo(invoke->method_index, &methodInfo);
-  if (NS_FAILED(rv))
-    goto end;
-
-  paramCount = methodInfo->GetParamCount();
-
-  params = new nsXPTCVariant[paramCount];
-  if (!params)
-    goto end;
-
-  // setup |params| for xptcall
-
-  for (i=0; i<paramCount; ++i, ++paramUsed)
-  {
-    const nsXPTParamInfo &paramInfo = methodInfo->GetParam(i);
-
-    // XXX are inout params an issue?
-
-    if (paramInfo.IsIn() && !paramInfo.IsDipper())
-      rv = DeserializeParam(reader, paramInfo.GetType(), params[i]);
-    else
-      rv = SetupParam(paramInfo, params[i]);
-
-    if (NS_FAILED(rv))
-      goto end;
-  }
-
-  // fixup any interface pointers.  we do this with a second pass so that
-  // we can properly handle INTERFACE_IS.
-  for (i=0; i<paramCount; ++i)
-  {
-    const nsXPTParamInfo &paramInfo = methodInfo->GetParam(i);
-    const nsXPTType &type = paramInfo.GetType();
-
-    if (paramInfo.IsIn() && type.IsInterfacePointer())
-    {
-      PtrBits bits = (PtrBits) params[i].ptr;
-      if (bits & 0x1)
-      {
-        // pointer is to a remote object.  we need to build a stub.
-        params[i].ptr = (void *) (bits & ~0x1);
-
-        nsID iid;
-        rv = GetIIDForMethodParam(iinfo, methodInfo, paramInfo, type,
-                                  invoke->method_index, i, params, PR_TRUE, iid);
-        if (NS_SUCCEEDED(rv))
-        {
-          DConnectStub *stub;
-          rv = CreateStub(iid, peer, (DConAddr) params[i].ptr, &stub);
-          if (NS_SUCCEEDED(rv))
-          {
-            params[i].val.p = params[i].ptr = stub;
-            params[i].SetValIsInterface();
-          }
-        }
-      }
-      else if (bits)
-      {
-        // pointer is to one of our instance wrappers.
-
-        DConnectInstance *wrapper = (DConnectInstance *) params[i].ptr;
-        params[i].val.p = params[i].ptr = wrapper->RealInstance();
-        params[i].SetValIsInterface();
-      }
-      else
-      {
-        params[i].val.p = params[i].ptr = nsnull;
-        params[i].SetValIsInterface();
-      }
-    }
-  }
-
-  rv = NS_InvokeByIndex(wrapper->RealInstance(),
-                        invoke->method_index, 
-                        paramCount,
-                        params);
-
-end:
-  LOG(("sending INVOKE_REPLY: rv=%x\n", rv));
-
-  ipcMessageWriter writer(64);
-
-  DConnectInvokeReply reply;
-  reply.opcode_major = DCON_OP_INVOKE_REPLY;
-  reply.opcode_minor = 0;
-  reply.request_index = invoke->request_index;
-  reply.result = rv;
-
-  writer.PutBytes(&reply, sizeof(reply));
-
-  nsVoidArray wrappers;
-
-  if (NS_SUCCEEDED(rv) && params)
-  {
-    // serialize out-params and retvals
-    for (i=0; i<paramCount; ++i)
-    {
-      const nsXPTParamInfo paramInfo = methodInfo->GetParam(i);
-
-      if (paramInfo.IsRetval() || paramInfo.IsOut())
-      {
-        const nsXPTType &type = paramInfo.GetType();
-
-        if (type.IsInterfacePointer())
-        {
-          nsID iid;
-          rv = GetIIDForMethodParam(iinfo, methodInfo, paramInfo, type,
-                                    invoke->method_index, i, params, PR_TRUE, iid);
-          if (NS_SUCCEEDED(rv))
-            rv = SerializeInterfaceParam(writer, peer, iid, type, params[i], wrappers);
-        }
-        else
-          rv = SerializeParam(writer, type, params[i]);
-
-        if (NS_FAILED(rv))
-        {
-          reply.result = rv;
-          break;
-        }
-      }
-    }
-  }
-
-  if (NS_FAILED(rv))