Skip to content
Browse files

- remove binary ipc

- use js-ctypes subprocess.jsm from Firefogg
- update compatible versions
  • Loading branch information...
1 parent 9fdde7e commit 0886d80dd28e3a51cdbf7bdac02e5f6d027bce4a @bit bit committed Nov 23, 2011
Showing with 959 additions and 8,540 deletions.
  1. +1 −2 build.sh
  2. +0 −8 chrome.manifest
  3. BIN components/firegpg_ipc.dll
  4. BIN components/firegpg_ipc.xpt
  5. BIN components/libfiregpg_ipc.32.so
  6. BIN components/libfiregpg_ipc.64.so
  7. BIN components/libfiregpg_ipc.dylib
  8. +1 −1 config_build.sh
  9. +12 −19 content/Core/cgpgaccess.js
  10. +1 −1 install.rdf
  11. +0 −11 ipc/README
  12. +0 −20 ipc/build_linux32.sh
  13. +0 −20 ipc/build_linux64.sh
  14. +0 −31 ipc/build_osx.sh
  15. +0 −21 ipc/build_win32.sh
  16. +0 −10 ipc/chrome.manifest
  17. BIN ipc/firegpg-ipc/.hg/00changelog.i
  18. +0 −1 ipc/firegpg-ipc/.hg/branch
  19. +0 −2 ipc/firegpg-ipc/.hg/branchheads.cache
  20. BIN ipc/firegpg-ipc/.hg/dirstate
  21. +0 −2 ipc/firegpg-ipc/.hg/hgrc
  22. +0 −4 ipc/firegpg-ipc/.hg/requires
  23. BIN ipc/firegpg-ipc/.hg/store/00changelog.i
  24. BIN ipc/firegpg-ipc/.hg/store/00manifest.i
  25. BIN ipc/firegpg-ipc/.hg/store/data/_makefile.in.i
  26. BIN ipc/firegpg-ipc/.hg/store/data/build/_makefile.in.i
  27. BIN ipc/firegpg-ipc/.hg/store/data/build/ns_i_p_c_module.cpp.i
  28. BIN ipc/firegpg-ipc/.hg/store/data/makemake.i
  29. BIN ipc/firegpg-ipc/.hg/store/data/modules/_makefile.in.i
  30. BIN ipc/firegpg-ipc/.hg/store/data/modules/subprocess.jsm.i
  31. BIN ipc/firegpg-ipc/.hg/store/data/public/_makefile.in.i
  32. BIN ipc/firegpg-ipc/.hg/store/data/public/ns_i_i_p_c_buffer.idl.i
  33. BIN ipc/firegpg-ipc/.hg/store/data/public/ns_i_pipe_listener.idl.i
  34. BIN ipc/firegpg-ipc/.hg/store/data/public/ns_i_pipe_transport.idl.i
  35. BIN ipc/firegpg-ipc/.hg/store/data/readme.txt.i
  36. BIN ipc/firegpg-ipc/.hg/store/data/src/_i_p_c_process.cpp.i
  37. BIN ipc/firegpg-ipc/.hg/store/data/src/_i_p_c_process.h.i
  38. BIN ipc/firegpg-ipc/.hg/store/data/src/_makefile.in.i
  39. BIN ipc/firegpg-ipc/.hg/store/data/src/ipc.h.i
  40. BIN ipc/firegpg-ipc/.hg/store/data/src/ns_i_p_c_buffer.cpp.i
  41. BIN ipc/firegpg-ipc/.hg/store/data/src/ns_i_p_c_buffer.h.i
  42. BIN ipc/firegpg-ipc/.hg/store/data/src/ns_pipe_transport.cpp.i
  43. BIN ipc/firegpg-ipc/.hg/store/data/src/ns_pipe_transport.h.i
  44. BIN ipc/firegpg-ipc/.hg/store/data/tests/_ipc_cat.cpp.i
  45. BIN ipc/firegpg-ipc/.hg/store/data/tests/_makefile.in.i
  46. BIN ipc/firegpg-ipc/.hg/store/data/tests/unit/test__ipcbuffer.js.i
  47. BIN ipc/firegpg-ipc/.hg/store/data/tests/unit/test__pipetrans.js.i
  48. BIN ipc/firegpg-ipc/.hg/store/data/tests/unit/test__subprocess.js.i
  49. BIN ipc/firegpg-ipc/.hg/store/data/~2ehgtags.i
  50. +0 −25 ipc/firegpg-ipc/.hg/store/fncache
  51. BIN ipc/firegpg-ipc/.hg/store/undo
  52. +0 −3 ipc/firegpg-ipc/.hg/tags.cache
  53. +0 −1 ipc/firegpg-ipc/.hg/undo.branch
  54. +0 −3 ipc/firegpg-ipc/.hg/undo.desc
  55. 0 ipc/firegpg-ipc/.hg/undo.dirstate
  56. +0 −1 ipc/firegpg-ipc/.hgtags
  57. +0 −53 ipc/firegpg-ipc/Makefile.in
  58. +0 −115 ipc/firegpg-ipc/build/Makefile.in
  59. +0 −69 ipc/firegpg-ipc/build/nsIPCModule.cpp
  60. +0 −193 ipc/firegpg-ipc/makemake
  61. +0 −52 ipc/firegpg-ipc/modules/Makefile.in
  62. +0 −422 ipc/firegpg-ipc/modules/subprocess.jsm
  63. +0 −53 ipc/firegpg-ipc/public/Makefile.in
  64. +0 −122 ipc/firegpg-ipc/public/nsIIPCBuffer.idl
  65. +0 −114 ipc/firegpg-ipc/public/nsIPipeListener.idl
  66. +0 −294 ipc/firegpg-ipc/public/nsIPipeTransport.idl
  67. +0 −16 ipc/firegpg-ipc/readme.txt
  68. +0 −684 ipc/firegpg-ipc/src/IPCProcess.cpp
  69. +0 −195 ipc/firegpg-ipc/src/IPCProcess.h
  70. +0 −89 ipc/firegpg-ipc/src/Makefile.in
  71. +0 −46 ipc/firegpg-ipc/src/ipc.h
  72. +0 −1,074 ipc/firegpg-ipc/src/nsIPCBuffer.cpp
  73. +0 −113 ipc/firegpg-ipc/src/nsIPCBuffer.h
  74. +0 −2,824 ipc/firegpg-ipc/src/nsPipeTransport.cpp
  75. +0 −414 ipc/firegpg-ipc/src/nsPipeTransport.h
  76. +0 −156 ipc/firegpg-ipc/tests/IpcCat.cpp
  77. +0 −62 ipc/firegpg-ipc/tests/Makefile.in
  78. +0 −245 ipc/firegpg-ipc/tests/unit/test_ipcbuffer.js
  79. +0 −342 ipc/firegpg-ipc/tests/unit/test_pipetrans.js
  80. +0 −251 ipc/firegpg-ipc/tests/unit/test_subprocess.js
  81. +0 −33 ipc/get.sh
  82. +944 −323 modules/subprocess.jsm
View
3 build.sh
@@ -15,7 +15,6 @@
# skin/ |
#
# defaults/ |
-# components/ |} these must be listed in $ROOT_DIRS in order to be packaged
# ... |
#
# It uses a temporary directory ./build when building; don't use that!
@@ -75,7 +74,7 @@ zip -0 -r $JAR_FILE `cat files` -x '*.svn*'
# The following statement should be used instead if you don't wish to use the JAR file
#cp --verbose --parents `cat files` $TMP_DIR/chrome
-# prepare components and defaults
+# prepare defaults
echo "Copying various files to $TMP_DIR folder..."
for DIR in $ROOT_DIRS; do
mkdir $TMP_DIR/$DIR
View
8 chrome.manifest
@@ -41,11 +41,3 @@ style chrome://global/content/customizeToolbar.xul chrome://fire
resource firegpg modules/
-interfaces components/firegpg_ipc.xpt
-binary-component components/libfiregpg_ipc.dylib ABI=Darwin_x86-gcc3
-binary-component components/libfiregpg_ipc.dylib ABI=Darwin_x86_64-gcc3
-binary-component components/libfiregpg_ipc.64.so ABI=Linux_x86_64-gcc3
-binary-component components/libfiregpg_ipc.32.so ABI=Linux_x86-gcc3
-binary-component components/firegpg_ipc.dll ABI=WINNT_x86-msvc
-contract @getfiregpg.org/ipc/ipc-buffer;1 {babce0c1-7ab1-11d4-8f02-a06008948af5}
-contract @getfiregpg.org/ipc/pipe-transport;1 {babce001-7ab1-11d4-8f02-a06008948af5}
View
BIN components/firegpg_ipc.dll
Binary file not shown.
View
BIN components/firegpg_ipc.xpt
Binary file not shown.
View
BIN components/libfiregpg_ipc.32.so
Binary file not shown.
View
BIN components/libfiregpg_ipc.64.so
Binary file not shown.
View
BIN components/libfiregpg_ipc.dylib
Binary file not shown.
View
2 config_build.sh
@@ -4,6 +4,6 @@ APP_NAME=firegpg
CHROME_PROVIDERS="content locale skin"
CLEAN_UP=1
ROOT_FILES="AUTHORS COPYING README"
-ROOT_DIRS="defaults components modules"
+ROOT_DIRS="defaults modules"
BEFORE_BUILD=
AFTER_BUILD=
View
31 content/Core/cgpgaccess.js
@@ -358,29 +358,29 @@ FireGPG.GPGAccess = {
Parameters:
parameters - The parameters for gnupg.
- sdtIn - The data to send to gnupg on the sdIn
- charset - _Optional_. The charset to read the sdtIn (UTF-8 by default)
+ stdIn - The data to send to gnupg on the sdIn
+ charset - _Optional_. The charset to read the stdIn (UTF-8 by default)
Return:
The sdOut (.out) and the sdErr (.err) of the execution
*/
- runGnupg: function(parameters, sdtIn, charset) {
+ runGnupg: function(parameters, stdIn, charset) {
if (charset == undefined)
charset = "utf-8";
- if (sdtIn == undefined)
- sdtIn = "";
+ if (stdIn == undefined)
+ stdIn = "";
- sdtIn = FireGPG.Misc.EnigConvertFromUnicode(sdtIn, charset);
+ stdIn = FireGPG.Misc.EnigConvertFromUnicode(stdIn, charset);
var outStrObj = new Object();
var outLenObj = new Object();
var errStrObj = new Object();
var errLenObj = new Object();
- FireGPG.debug(this.getGPGCommand() + " " + parameters + "[" + sdtIn + "]",'FireGPGGPGAccessCallerUnixXpcom');
+ FireGPG.debug(this.getGPGCommand() + " " + parameters + "[" + stdIn + "]",'FireGPGGPGAccessCallerUnixXpcom');
var parametersS = parameters.split(/ /gi);
@@ -416,22 +416,15 @@ FireGPG.GPGAccess = {
var p = subprocess.call({
command: this.getGPGCommand(),
arguments: gpgArgs,
- onFinished: subprocess.Terminate(function() {
+ done: function(result) {
+ retour.err = result.stderr;
+ retour.out = result.stdout;
retour.out = FireGPG.Misc.EnigConvertToUnicode(retour.out,
charset);
retour.err = FireGPG.Misc.EnigConvertToUnicode(retour.err,
charset);
- }),
- stderr: subprocess.ReadablePipe(function(data) {
- retour.err += data;
- }),
- stdout: subprocess.ReadablePipe(function(data) {
- retour.out += data;
- }),
- stdin: subprocess.WritablePipe(function() {
- this.write(sdtIn);
- this.close();
- })
+ },
+ stdin: stdIn
});
p.wait();
return retour;
View
2 install.rdf
@@ -6,7 +6,7 @@
em:id="{ec8030f7-c20a-464f-9b0e-13a3a9e97384}"
em:minVersion="6.0"
- em:maxVersion="6.*" />
+ em:maxVersion="10.*" />
<RDF:Description RDF:about="urn:mozilla:install-manifest"
em:id="firegpg@firegpg.team"
em:version="0.8.5"
View
11 ipc/README
@@ -1,11 +0,0 @@
-ipc needs to be build on each platform
-
-./get.sh this checks out ipc code and patches it for use this extension
-./build_* build scripts for each platform, expects mozilla-central in ~/src/
-
-after building you need to move all files in:
- components/ to extension/components/
- ipc*/modules/subprocess.jsm to extension/modules/subprocess.jsm
-
-add contents of chrome.manifest to extension/chrome.manifest
-
View
20 ipc/build_linux32.sh
@@ -1,20 +0,0 @@
-#!/bin/bash
-name=firegpg
-MOZBUILD=$HOME/src/mozilla-beta/obj-ff-release
-
-cd `dirname $0`
-IPC=`pwd`
-
-ln -sf $IPC/$name-ipc $MOZBUILD/../extensions/$name-ipc
-
-cd $MOZBUILD
-../build/autoconf/make-makefile extensions/$name-ipc
-cd $MOZBUILD/extensions/$name-ipc
-make
-
-#install
-COMPONENTS=$IPC/components/
-mkdir -p $COMPONENTS
-cp ../../dist/bin/components/lib${name}_ipc.so $COMPONENTS/lib${name}_ipc.32.so
-strip $COMPONENTS/lib${name}_ipc.32.so
-cp ../../dist/bin/components/${name}_ipc.xpt $COMPONENTS
View
20 ipc/build_linux64.sh
@@ -1,20 +0,0 @@
-#!/bin/bash
-name=firegpg
-MOZBUILD=$HOME/src/mozilla-beta/obj-ff-release
-
-cd `dirname $0`
-IPC=`pwd`
-
-ln -sf $IPC/$name-ipc $MOZBUILD/../extensions/$name-ipc
-
-cd $MOZBUILD
-../build/autoconf/make-makefile extensions/$name-ipc
-cd $MOZBUILD/extensions/$name-ipc
-make
-
-#install
-COMPONENTS=$IPC/components/
-mkdir -p $COMPONENTS
-cp ../../dist/bin/components/lib${name}_ipc.so $COMPONENTS/lib${name}_ipc.64.so
-strip $COMPONENTS/lib${name}_ipc.64.so
-cp ../../dist/bin/components/${name}_ipc.xpt $COMPONENTS
View
31 ipc/build_osx.sh
@@ -1,31 +0,0 @@
-#!/bin/bash
-name=firegpg
-MOZBUILD=$HOME/src/mozilla-beta/obj-x86_64-apple-darwin10.8.0
-
-cd `dirname $0`
-IPC=`pwd`
-
-rm -rf $MOZBUILD/../extensions/$name-ipc
-cp -r $IPC/$name-ipc $MOZBUILD/../extensions/$name-ipc
-
-arch=i386
-cd $MOZBUILD/$arch
-../../build/autoconf/make-makefile extensions/$name-ipc
-cd $MOZBUILD/$arch/extensions/$name-ipc
-make
-
-arch=x86_64
-cd $MOZBUILD/$arch
-../../build/autoconf/make-makefile extensions/$name-ipc
-cd $MOZBUILD/$arch/extensions/$name-ipc
-make
-
-COMPONENTS=$IPC/components/
-mkdir -p $COMPONENTS
-
-lipo -create \
- -arch i386 $MOZBUILD/i386/dist/bin/components/lib${name}_ipc.dylib \
- -arch x86_64 $MOZBUILD/x86_64/dist/bin/components/lib${name}_ipc.dylib \
- -output $COMPONENTS/lib${name}_ipc.dylib
-strip -S $COMPONENTS/lib${name}_ipc.dylib
-cp ../../dist/bin/components/${name}_ipc.xpt $COMPONENTS
View
21 ipc/build_win32.sh
@@ -1,21 +0,0 @@
-#!/bin/sh
-name=firegpg
-MOZBUILD=$HOME/src/mozilla-beta/ff-opt
-
-cd `dirname $0`
-
-IPC=`pwd`
-
-rm -rf $MOZBUILD/../extensions/$name-ipc
-cp -r $IPC/$name-ipc $MOZBUILD/../extensions/$name-ipc
-
-
-cd $MOZBUILD
-../build/autoconf/make-makefile extensions/$name-ipc
-cd $MOZBUILD/extensions/$name-ipc
-make
-
-COMPONENTS=$IPC/components/
-mkdir -p $COMPONENTS
-cp ../../dist/bin/components/${name}_ipc.dll $COMPONENTS
-cp ../../dist/bin/components/${name}_ipc.xpt $COMPONENTS
View
10 ipc/chrome.manifest
@@ -1,10 +0,0 @@
-resource firegpg modules/
-
-interfaces components/firegpg_ipc.xpt
-binary-component components/libfiregpg_ipc.dylib ABI=Darwin_x86-gcc3
-binary-component components/libfiregpg_ipc.dylib ABI=Darwin_x86_64-gcc3
-binary-component components/libfiregpg_ipc.64.so ABI=Linux_x86_64-gcc3
-binary-component components/libfiregpg_ipc.32.so ABI=Linux_x86-gcc3
-binary-component components/firegpg_ipc.dll ABI=WINNT_x86-msvc
-contract @getfiregpg.org/ipc/ipc-buffer;1 {babce0c1-7ab1-11d4-8f02-a06008948af5}
-contract @getfiregpg.org/ipc/pipe-transport;1 {babce001-7ab1-11d4-8f02-a06008948af5}
View
BIN ipc/firegpg-ipc/.hg/00changelog.i
Binary file not shown.
View
1 ipc/firegpg-ipc/.hg/branch
@@ -1 +0,0 @@
-default
View
2 ipc/firegpg-ipc/.hg/branchheads.cache
@@ -1,2 +0,0 @@
-3aa8d8e7a70a4ec2fe6fa1499b4c4cbbb7cc3e48 2
-3aa8d8e7a70a4ec2fe6fa1499b4c4cbbb7cc3e48 default
View
BIN ipc/firegpg-ipc/.hg/dirstate
Binary file not shown.
View
2 ipc/firegpg-ipc/.hg/hgrc
@@ -1,2 +0,0 @@
-[paths]
-default = http://hg.mozilla.org/ipccode
View
4 ipc/firegpg-ipc/.hg/requires
@@ -1,4 +0,0 @@
-revlogv1
-store
-fncache
-dotencode
View
BIN ipc/firegpg-ipc/.hg/store/00changelog.i
Binary file not shown.
View
BIN ipc/firegpg-ipc/.hg/store/00manifest.i
Binary file not shown.
View
BIN ipc/firegpg-ipc/.hg/store/data/_makefile.in.i
Binary file not shown.
View
BIN ipc/firegpg-ipc/.hg/store/data/build/_makefile.in.i
Binary file not shown.
View
BIN ipc/firegpg-ipc/.hg/store/data/build/ns_i_p_c_module.cpp.i
Binary file not shown.
View
BIN ipc/firegpg-ipc/.hg/store/data/makemake.i
Binary file not shown.
View
BIN ipc/firegpg-ipc/.hg/store/data/modules/_makefile.in.i
Binary file not shown.
View
BIN ipc/firegpg-ipc/.hg/store/data/modules/subprocess.jsm.i
Binary file not shown.
View
BIN ipc/firegpg-ipc/.hg/store/data/public/_makefile.in.i
Binary file not shown.
View
BIN ipc/firegpg-ipc/.hg/store/data/public/ns_i_i_p_c_buffer.idl.i
Binary file not shown.
View
BIN ipc/firegpg-ipc/.hg/store/data/public/ns_i_pipe_listener.idl.i
Binary file not shown.
View
BIN ipc/firegpg-ipc/.hg/store/data/public/ns_i_pipe_transport.idl.i
Binary file not shown.
View
BIN ipc/firegpg-ipc/.hg/store/data/readme.txt.i
Binary file not shown.
View
BIN ipc/firegpg-ipc/.hg/store/data/src/_i_p_c_process.cpp.i
Binary file not shown.
View
BIN ipc/firegpg-ipc/.hg/store/data/src/_i_p_c_process.h.i
Binary file not shown.
View
BIN ipc/firegpg-ipc/.hg/store/data/src/_makefile.in.i
Binary file not shown.
View
BIN ipc/firegpg-ipc/.hg/store/data/src/ipc.h.i
Binary file not shown.
View
BIN ipc/firegpg-ipc/.hg/store/data/src/ns_i_p_c_buffer.cpp.i
Binary file not shown.
View
BIN ipc/firegpg-ipc/.hg/store/data/src/ns_i_p_c_buffer.h.i
Binary file not shown.
View
BIN ipc/firegpg-ipc/.hg/store/data/src/ns_pipe_transport.cpp.i
Binary file not shown.
View
BIN ipc/firegpg-ipc/.hg/store/data/src/ns_pipe_transport.h.i
Binary file not shown.
View
BIN ipc/firegpg-ipc/.hg/store/data/tests/_ipc_cat.cpp.i
Binary file not shown.
View
BIN ipc/firegpg-ipc/.hg/store/data/tests/_makefile.in.i
Binary file not shown.
View
BIN ipc/firegpg-ipc/.hg/store/data/tests/unit/test__ipcbuffer.js.i
Binary file not shown.
View
BIN ipc/firegpg-ipc/.hg/store/data/tests/unit/test__pipetrans.js.i
Binary file not shown.
View
BIN ipc/firegpg-ipc/.hg/store/data/tests/unit/test__subprocess.js.i
Binary file not shown.
View
BIN ipc/firegpg-ipc/.hg/store/data/~2ehgtags.i
Binary file not shown.
View
25 ipc/firegpg-ipc/.hg/store/fncache
@@ -1,25 +0,0 @@
-data/.hgtags.i
-data/Makefile.in.i
-data/build/Makefile.in.i
-data/build/nsIPCModule.cpp.i
-data/makemake.i
-data/modules/Makefile.in.i
-data/modules/subprocess.jsm.i
-data/public/Makefile.in.i
-data/public/nsIIPCBuffer.idl.i
-data/public/nsIPipeListener.idl.i
-data/public/nsIPipeTransport.idl.i
-data/readme.txt.i
-data/src/IPCProcess.cpp.i
-data/src/IPCProcess.h.i
-data/src/Makefile.in.i
-data/src/ipc.h.i
-data/src/nsIPCBuffer.cpp.i
-data/src/nsIPCBuffer.h.i
-data/src/nsPipeTransport.cpp.i
-data/src/nsPipeTransport.h.i
-data/tests/IpcCat.cpp.i
-data/tests/Makefile.in.i
-data/tests/unit/test_ipcbuffer.js.i
-data/tests/unit/test_pipetrans.js.i
-data/tests/unit/test_subprocess.js.i
View
BIN ipc/firegpg-ipc/.hg/store/undo
Binary file not shown.
View
3 ipc/firegpg-ipc/.hg/tags.cache
@@ -1,3 +0,0 @@
-2 3aa8d8e7a70a4ec2fe6fa1499b4c4cbbb7cc3e48 6c9c742a2408af25fc6db7a39a39ab71a35fbe79
-
-d014d4a1bac10e7131c3a1bb17859034a3839b65 gecko-192
View
1 ipc/firegpg-ipc/.hg/undo.branch
@@ -1 +0,0 @@
-default
View
3 ipc/firegpg-ipc/.hg/undo.desc
@@ -1,3 +0,0 @@
-0
-pull
-http://hg.mozilla.org/ipccode
View
0 ipc/firegpg-ipc/.hg/undo.dirstate
No changes.
View
1 ipc/firegpg-ipc/.hgtags
@@ -1 +0,0 @@
-d014d4a1bac10e7131c3a1bb17859034a3839b65 gecko-192
View
53 ipc/firegpg-ipc/Makefile.in
@@ -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 "MPL"); you may not use this file
-# except in compliance with the MPL. You may obtain a copy of
-# the MPL at http://www.mozilla.org/MPL/
-#
-# Software distributed under the MPL is distributed on an "AS
-# IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
-# implied. See the MPL for the specific language governing
-# rights and limitations under the MPL.
-#
-# The Original Code is protoZilla.
-#
-# The Initial Developer of the Original Code is Ramalingam Saravanan.
-# Portions created by Ramalingam Saravanan <svn@xmlterm.org> are
-# Copyright (C) 2001 Ramalingam Saravanan. All Rights Reserved.
-#
-# Contributor(s):
-# Patrick Brunschwig <patrick@mozilla-enigmail.org>
-#
-# 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 \
- build \
- modules
-
-ifdef ENABLE_TESTS
- DIRS += tests
-endif
-
-include $(topsrcdir)/config/rules.mk
View
115 ipc/firegpg-ipc/build/Makefile.in
@@ -1,115 +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 "MPL"); you may not use this file
-# except in compliance with the MPL. You may obtain a copy of
-# the MPL at http://www.mozilla.org/MPL/
-#
-# Software distributed under the MPL is distributed on an "AS
-# IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
-# implied. See the MPL for the specific language governing
-# rights and limitations under the MPL.
-#
-# The Original Code is protoZilla.
-#
-# The Initial Developer of the Original Code is Ramalingam Saravanan.
-# Portions created by Ramalingam Saravanan <svn@xmlterm.org> are
-# Copyright (C) 2001 Ramalingam Saravanan. All Rights Reserved.
-#
-# Contributor(s):
-# Patrick Brunschwig <patrick@mozilla-enigmail.org>
-#
-# 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
-
-XPI_MODULE = firegpg_ipc
-XPI_MODULE_VERS = 1.3.0
-
-MODULE = firegpg_ipc
-LIBRARY_NAME = firegpg_ipc
-SHORT_LIBNAME = firegpg_ipc
-
-IS_COMPONENT = 1
-FORCE_SHARED_LIB = 1
-EXTRA_BUILD_OPTS =
-
-ifeq ($(OS_ARCH),WINNT)
- EXPORT_LIBRARY = 0
- USE_STATIC_LIBS = 1
- EXTRA_BUILD_OPTS = /NODEFAULTLIB:LIBCMT
- FORCE_SHARED_LIB = 0
-endif
-
-MOZILLA_VERSION_PARTS = $(subst ., ,$(MOZILLA_VERSION))
-MOZILLA_MAJOR_VERSION = $(firstword $(MOZILLA_VERSION_PARTS))
-TMP_VAR = $(word 2,$(MOZILLA_VERSION_PARTS))
-MOZILLA_MINOR_VERSION = $(shell echo $(TMP_VAR)|sed 's/[a-z].*//')
-
-DEFINES += -DMOZILLA_MAJOR_VERSION=$(MOZILLA_MAJOR_VERSION)
-DEFINES += -DMOZILLA_MINOR_VERSION=$(MOZILLA_MINOR_VERSION)
-
-
-ifdef USE_XPCOM_GLUE
-# Ensure that the xpcom classes that we build
-# do not export themselves
-DEFINES += -D_IMPL_NS_COM_OFF -DXPCOM_GLUE
-endif
-
-REQUIRES = xpcom \
- string \
- js \
- caps \
- uconv \
- necko \
- xpconnect \
- $(NULL)
-
-MODULE_NAME = IPCModule
-
-CPPSRCS = nsIPCModule.cpp
-
-# hack to build non standard library dependent build on unix
-ifeq ($(IPC_STATIC),1)
-BUILD_STATIC = -nodefaultlibs -Xlinker --unresolved-symbols=ignore-all
-else
-BUILD_STATIC =
-endif
-
-
-SHARED_LIBRARY_LIBS = \
- ../src/$(LIB_PREFIX)ipc_s.$(LIB_SUFFIX) \
- $(NULL)
-
-LOCAL_INCLUDES = \
- -I$(srcdir)/../src \
- $(NULL)
-
-EXTRA_DSO_LDOPTS = \
- $(LIBS_DIR) \
- $(XPCOM_GLUE_LDOPTS) \
- $(XPCOM_LIBS) \
- $(NSPR_LIBS) \
- $(BUILD_STATIC) \
- $(EXTRA_BUILD_OPTS) \
- $(NULL)
-
-include $(topsrcdir)/config/rules.mk
View
69 ipc/firegpg-ipc/build/nsIPCModule.cpp
@@ -1,69 +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 "MPL"); you may not use this file
- * except in compliance with the MPL. You may obtain a copy of
- * the MPL at http://www.mozilla.org/MPL/
- *
- * Software distributed under the MPL is distributed on an "AS
- * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
- * implied. See the MPL for the specific language governing
- * rights and limitations under the MPL.
- *
- * The Original Code is protoZilla.
- *
- * The Initial Developer of the Original Code is Ramalingam Saravanan.
- * Portions created by Ramalingam Saravanan <svn@xmlterm.org> are
- * Copyright (C) 2000 Ramalingam Saravanan. All Rights Reserved.
- *
- * Contributor(s):
- * Patrick Brunschwig <patrick@mozilla-enigmail.org>
- *
- * 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 "ipc.h"
-#include "nsIClassInfoImpl.h"
-
-#include "nsPipeTransport.h"
-#include "nsIPCBuffer.h"
-
-#include "mozilla/ModuleUtils.h"
-
-NS_GENERIC_FACTORY_CONSTRUCTOR(nsPipeTransport)
-NS_GENERIC_FACTORY_CONSTRUCTOR(nsIPCBuffer)
-
-NS_DEFINE_NAMED_CID(NS_PIPETRANSPORT_CID);
-NS_DEFINE_NAMED_CID(NS_IPCBUFFER_CID);
-
-const mozilla::Module::CIDEntry kIPCModuleCIDs[] = {
- { &kNS_PIPETRANSPORT_CID, false, NULL, nsPipeTransportConstructor },
- { &kNS_IPCBUFFER_CID, false, NULL, nsIPCBufferConstructor },
- { NULL }
-};
-
-const mozilla::Module::ContractIDEntry kIPCModuleContracts[] = {
- { NS_PIPETRANSPORT_CONTRACTID, &kNS_PIPETRANSPORT_CID },
- { NS_IPCBUFFER_CONTRACTID, &kNS_IPCBUFFER_CID },
- { NULL }
-};
-
-static const mozilla::Module kIPCModule = {
- mozilla::Module::kVersion,
- kIPCModuleCIDs,
- kIPCModuleContracts,
- NULL
-};
-
-NSMODULE_DEFN(nsIPCModule) = &kIPCModule;
View
193 ipc/firegpg-ipc/makemake
@@ -1,193 +0,0 @@
-#!/usr/bin/perl
-
-# **** 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 "MPL"); you may not use this file
-# except in compliance with the MPL. You may obtain a copy of
-# the MPL at http://www.mozilla.org/MPL/
-#
-# Software distributed under the MPL is distributed on an "AS
-# IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
-# implied. See the MPL for the specific language governing
-# rights and limitations under the MPL.
-#
-# The Original Code is ipccode.
-#
-# The Initial Developer of the Original Code is Patrick Brunschwig.
-# Portions created by Patrick Brunschwig <patrick@mozilla-enigmail.org> are
-# Copyright (C) 2011 Patrick Brunschwig. 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 *****
-
-# makemake: script to generate Makefile from Makefile.in
-# -r: process recursively all subdirectories
-# -o DIR: use DIR as MOZ_OBJDIR
-# Usage: makemake [-o @TOPSRCDIR@/somedir] [-r]
-
-my $makelist="./Makefile.in";
-my $mozObjDir=".";
-my $makefile;
-
-my $cwd=`pwd`;
-chomp($cwd);
-my $topdir=$cwd;
-my $depth="";
-
-open(MAKEFILE, $makelist) || die ("Could not open '$makelist'\n");
-while (my $l = <MAKEFILE>) {
- chomp($l);
- if ($l =~ /^\s*DEPTH\s*=/) {
- $l =~ s/(^\s*DEPTH\s*=\s*)(.*)$/$2/;
- $depth = $l;
- }
-}
-close(MAKEFILE);
-
-if ($depth eq "") {
- while ( (length($topdir)>0) && ( basename($topdir) ne "mozilla" )) {
- $topdir=dirname($topdir);
- }
-}
-else {
- chdir($depth) || die "Directory '$depth' not found\n";
- chdir("..");
- $topdir=`pwd`;
- chomp($topdir);
- chdir($cwd);
-}
-print "INFO: found toplevel source directory $topdir\n";
-
-
-if (open(MOZCONFIG, "$topdir/.mozconfig")) {
- while (my $l = <MOZCONFIG>) {
- chomp($l);
- if ($l =~ /^\s*mk_add_options\s+MOZ_OBJDIR\s*=/) {
- $l =~ s/(^\s*mk_add_options\s+MOZ_OBJDIR\s*=\s*)(.*)$/$2/;
- $mozObjDir = $l;
- }
- }
- close(MOZCONFIG);
-}
-else {
- print "INFO: no .mozconfig file found\n";
-}
-
-
-while ( $#ARGV >= 0 ) {
- if ($ARGV[0] eq "-o") {
- $mozObjDir=$ARGV[1];
- shift @ARGV;
- }
- if ($ARGV[0] eq "-r") {
- $makelist=`find . -name Makefile.in -print`;
- break;
- }
- shift @ARGV;
-}
-
-
-$mozObjDir =~ s/\@TOPSRCDIR\@/$topdir/;
-
-if ($mozObjDir eq ".") {
- print "INFO: no MOZ_OBJDIR used\n";
-}
-else {
- print "INFO: using MOZ_OBJDIR=$mozObjDir\n\n";
-}
-
-foreach $makefile (split(/[ \n\r]+/, $makelist)) {
- $makefile =~ s/^\.\///;
- my $dir=dirname("$cwd/$makefile");
-
- my $wd=$dir;
- print "Processing: $wd\n";
- my $top_srcdir="";
- my $newMakefile = $makefile;
- $newMakefile =~ s/.in$//;
-
- if ($mozObjDir eq ".") {
- # no OBJDIR specified
- if ($depth eq "") {
- while ( (length($wd)>0) && (basename($wd) ne "mozilla") ) {
- if (length($top_srcdir) == 0) {
- $top_srcdir="..";
- }
- else {
- $top_srcdir="../$top_srcdir";
- }
- $wd=dirname($wd);
- }
- }
- else {
- $top_srcdir=$topdir;
- }
- $srcdir=".";
- }
- else {
- # using OBJDIR
- if ($depth eq "") {
- # while ( (length($wd)>0) && (basename($wd) ne "mozilla") ) {
- while ( length($wd)>0 ) {
- $wd=dirname($wd);
- }
- $top_srcdir="$wd";
- }
- else {
- $top_srcdir="$topdir";
- }
- $srcdir=$dir;
- my $targetDir=$srcdir;
- $targetDir =~ s/$top_srcdir/$mozObjDir/x;
- system("mkdir -p '$targetDir'");
- $newMakefile=sprintf("%s/%s", $targetDir, basename($newMakefile));
- }
-
- # print "Creating file $newMakefile\n";
- open(INFILE, $makefile) || die ("cannot open input file '$makefile'\n");
- open(OUTFILE, ">$newMakefile") || die ("cannot open output file '$newMakefile'\n");
-
- my $line;
- while ($line = <INFILE>) {
- $line =~ s/\@srcdir\@/$srcdir/g;
- $line =~ s/\@top_srcdir\@/$top_srcdir\/mozilla/g;
- print OUTFILE $line;
- }
- close(INFILE);
- close(OUTFILE);
-}
-
-if ($mozObjDir eq ".") {
- print "Done\n\n";
-}
-else {
- my $newWd=$cwd;
- $newWd =~ s/$topdir/$mozObjDir/x;
- print "Done. The code can now be compiled from $newWd\n\n";
-}
-
-sub basename {
- my $fn=$_[0];
- $fn =~ s/^(.*)\/(.*)$/$2/;
- return $fn;
-}
-
-sub dirname {
- my $dn=$_[0];
- $dn =~ s/^(.*)\/(.*)$/$1/;
- return $dn;
-}
View
52 ipc/firegpg-ipc/modules/Makefile.in
@@ -1,52 +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 "MPL"); you may not use this file
-# except in compliance with the MPL. You may obtain a copy of
-# the MPL at http://www.mozilla.org/MPL/
-#
-# Software distributed under the MPL is distributed on an "AS
-# IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
-# implied. See the MPL for the specific language governing
-# rights and limitations under the MPL.
-#
-# The Original Code is protoZilla.
-#
-# The Initial Developer of the Original Code is Ramalingam Saravanan.
-# Portions created by Ramalingam Saravanan <svn@xmlterm.org> are
-# Copyright (C) 2001 Ramalingam Saravanan. All Rights Reserved.
-#
-# Contributor(s):
-# Patrick Brunschwig <patrick@mozilla-enigmail.org>
-#
-# 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 *****
-
-
-# Makefile for package directory
-
-# Specify these as parameters to the make command
-
-DEPTH = ../../..
-topsrcdir = @top_srcdir@
-srcdir = @srcdir@
-VPATH = @srcdir@
-
-include $(DEPTH)/config/autoconf.mk
-
-EXTRA_JS_MODULES = \
- subprocess.jsm \
- $(NULL)
-
-include $(topsrcdir)/config/rules.mk
View
422 ipc/firegpg-ipc/modules/subprocess.jsm
@@ -1,422 +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 "MPL"); you may not use this file
- * except in compliance with the MPL. You may obtain a copy of
- * the MPL at http://www.mozilla.org/MPL/
- *
- * Software distributed under the MPL is distributed on an "AS
- * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
- * implied. See the MPL for the specific language governing
- * rights and limitations under the MPL.
- *
- * The Original Code is IPC-Pipe.
- *
- * The Initial Developer of this code is Patrick Brunschwig.
- * Portions created by Patrick Brunschwig <patrick@mozilla-enigmail.org>
- * are Copyright (C) 2010 Patrick Brunschwig.
- * 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 ***** */
-
-
-/*
- * Import into a JS component using
- * 'Components.utils.import("resource://gre/modules/subprocess.jsm");'
- *
- * This object allows to start a process, and read/write data to/from it
- * using stdin/stdout/stderr streams.
- * Usage example:
- *
- * var p = subprocess.call({
- * command: '/bin/foo',
- * arguments: ['-v', 'foo'],
- * environment: [ "XYZ=abc", "MYVAR=def" ],
- * workdir: '/home/foo',
- * stdin: subprocess.WritablePipe(function() {
- * this.write("Writing example data\n");
- * this.close();
- * }),
- * stdout: subprocess.ReadablePipe(function(data) {
- * dump("got data on stdout:" +data+"\n");
- * }),
- * stderr: subprocess.ReadablePipe(function(data) {
- * dump("got data on stderr:" +data+"\n");
- * }),
- * onFinished: subprocess.Terminate(function() {
- * dump("process terminated with " +this.exitCode + "\n");
- * }),
- * mergeStderr: false
- * });
- * p.wait(); // wait for the subprocess to terminate
- *
- *
- * Description of parameters:
- * --------------------------
- * Apart from <command>, all arguments are optional.
- *
- * command: either a |nsIFile| object pointing to an executable file or a
- * String containing the platform-dependent path to an executable
- * file.
- *
- * arguments: optional string array containing the arguments to the command.
- *
- * environment: optional string array containing environment variables to pass
- * to the command. The array elements must have the form
- * "VAR=data". Please note that if environment is defined, it
- * replaces any existing environment variables for the subprocess.
- *
- * workdir: optional; either a |nsIFile| object pointing to a directory or a
- * String containing the platform-dependent path to a directory to
- * become the current working directory of the subprocess.
- *
- * stdin: optional input data for the process to be passed on standard
- * input. stdin can either be a string or a function. If stdin is a
- * string, then the string content is passed to the process. If
- * stdin is a function defined using subprocess.WritablePipe, input
- * data can be written synchronously to the process using
- * this.write(string).
- * The stream to the subprocess can be closed with this.close().
- *
- * stdout: an optional function that can receive output data from the
- * process. The stdout-function is called asynchronously; it can be
- * called mutliple times during the execution of a process. Please
- * note that null-characters might need to be escaped with
- * something like 'data.replace(/\0/g, "\\0");'.
- * stdout needs to be defined using subprocess.ReadablePipe.
- *
- * stderr: an optional function that can receive output sent to stderr. The
- * function is only called synchronously when the process has
- * terminated. Again, null-characters might need to be escaped.
- * stderr needs to be defined using subprocess.ReadablePipe.
- *
- * onFinished: optional function that is called when the process has terminated.
- * The exit code from the process available via this.exitCode. If
- * stdout is not defined, then the output from stdout is available
- * via this.stdoutData. onFinished needs to be defined using
- * subprocess.Terminate.
- *
- * mergeStderr: optional boolean value. If true, stderr is merged with stdout;
- * no data will be provided to stderr.
- *
- *
- * Description of object returned by subprocess.call(...)
- * ------------------------------------------------------
- * The object returned by subprocess.call offers a few methods that can be
- * executed:
- *
- * wait(): waits for the subprocess to terminate. It is not required to use
- * wait; onFinshed and stderr will be called in any case when the
- * subprocess terminated.
- *
- * kill(): kill the subprocess. Any open pipes will be closed and
- * onFinished will be called.
- *
- *
- * Important notes
- * ---------------
- *
- * Be careful if you create more than one subprocess in parallel. Because
- * p.wait() is blocking the termination of other processes, you cannot wait on
- * the same thread for more than one subprocess to terminate, unless you know
- * the sequence in which the subprocesses finish. Therefore it is safer to
- * create new threads if you need to execute several subprocesses at the same
- * time.
- *
- */
-
-
-Components.utils.import("resource://gre/modules/XPCOMUtils.jsm");
-
-var EXPORTED_SYMBOLS = [ "subprocess" ];
-
-const NS_PIPETRANSPORT_CONTRACTID = "@getfiregpg.org/ipc/pipe-transport;1";
-const NS_IPCBUFFER_CONTRACTID = "@getfiregpg.org/ipc/ipc-buffer;1";
-const Cc = Components.classes;
-const Ci = Components.interfaces;
-
-var subprocess = {
-
- /**
- * Constructor method to create a subprocess.
- *
- * @param commandObj object defining the input parameters. See documentation
- * above for details.
- */
- call: function (commandObj) {
- var pipeObj = new PipeObj();
- if (! pipeObj) return null;
- pipeObj.init(commandObj);
- return pipeObj;
- },
- /**
- * Create a pipe that writes data to the subprocess
- *
- * @param func function definition that implements writing to the pipe
- * using "this.write(txt)".
- */
- WritablePipe: function(func) {
- var pipeWriterObj = {
- _pipeTransport: null,
- write: function(data) {
- this._pipeTransport.writeSync(data, data.length);
- },
- close: function() {
- this._pipeTransport.closeStdin();
- },
- startWriting: func
- };
- return pipeWriterObj;
- },
- /**
- * Create a pipe that read data from the subprocess (stdout or stderr)
- *
- * @param func function definition that implements reading from the pipe.
- * The 1st parameter holds the data read from the subprocess.
- */
- ReadablePipe: function(func) {
- var pipeReaderObj = {
- callbackFunction: func,
- onDataAvailable: function(data) {
- this.callbackFunction(data);
- }
- }
- return pipeReaderObj;
- },
- /**
- * Create a function that listens to the termination of the subprocess.
- *
- * @param func function definition that implements the listener.
- */
- Terminate: function(func) {
- var onFinishedObj = {
- stdoutData: null,
- callbackFunction: func,
- callback: function (exitCode) {
- this.exitCode = exitCode;
- this.callbackFunction();
- }
- };
- return onFinishedObj;
- },
-};
-
-
-/**
- * Stream Listener object for handling callbacks from the subprocess' stdout
- */
-function StdoutStreamListener(cmdObj)
-{
- this._cmdObj = cmdObj;
- this._reqObserver = null;
-}
-
-StdoutStreamListener.prototype = {
- QueryInterface: XPCOMUtils.generateQI(
- [ Ci.nsIRequestObserver, Ci.nsIStreamListener ]),
-
- // nsIObserver
- observe: function (aReqObserver, aContext) {
- this._reqObserver = aReqObserver;
- },
-
- // nsIRequestObserver
- onStartRequest: function(aRequest, aContext) {
- if (this._reqObserver)
- this._reqObserver.onStartRequest(aRequest, aContext);
- },
-
- // nsIRequestObserver
- onStopRequest: function(aRequest, aContext, aStatusCode) {
- // call to stderr and onFinished from here to avoid mandatory use of
- // p.wait()
- if (this._reqObserver)
- this._reqObserver.onStopRequest(aRequest, aContext, aStatusCode);
-
- // unset assigned variables to avoid memory leak
- this._reqObserver=null;
- this._cmdObj=null;
- },
-
- // nsIStreamListener
- onDataAvailable: function(aRequest, aContext, aInputStream, offset, count) {
-
- let sis = Cc["@mozilla.org/scriptableinputstream;1"].createInstance(
- Ci.nsIScriptableInputStream);
- sis.init(aInputStream);
- if ("readBytes" in sis) {
- // Gecko > 2.0b4, supports NULL characters
- this._cmdObj.stdout.onDataAvailable(sis.readBytes(count));
- }
- else
- // Gecko <= 2.0b4
- this._cmdObj.stdout.onDataAvailable(sis.read(count));
-
- // unset variable to avoid memory leak
- sis = null;
- }
-
-};
-
-/**
- * Listener for handling subprocess termination
- */
-function OnFinishedListener(pipeObj)
-{
- this._pipeObj = pipeObj;
-}
-
-OnFinishedListener.prototype = {
- QueryInterface: XPCOMUtils.generateQI([ Ci.nsIRequestObserver ]),
-
- // nsIRequestObserver
- onStartRequest: function(aRequest, aContext) {
- // do nothing
- },
-
- // nsIRequestObserver
- onStopRequest: function(aRequest, aContext, aStatusCode) {
-
- // call to stderr and onFinished from here to avoid mandatory use of
- // p.wait()
-
- let cmdObj = this._pipeObj._cmdObj;
-
- if (typeof(cmdObj.stderr) == "object" && (! cmdObj.mergeStderr)) {
- cmdObj.stderr.onDataAvailable( this._pipeObj.stderrData.getData());
- this._pipeObj.stderrData.shutdown();
- }
-
- if (typeof(cmdObj.onFinished) == "object") {
- if (cmdObj.stdout == null) {
- cmdObj.onFinished.stdoutData =
- this._pipeObj.stdoutListener.getData();
- this._pipeObj.stdoutListener.shutdown();
- }
-
- cmdObj.onFinished.callback(this._pipeObj._pipeTransport.exitValue);
- }
-
- // unset assigned variables to avoid memory leak
- this._pipeObj = null;
- }
-}
-
-/**
- * Class to represent a running process. This class that is returned
- * from subprocess.call(...)
- */
-function PipeObj()
-{}
-
-PipeObj.prototype = {
- stderrData: null,
-
- /**
- * Initializer method.
- *
- * @param cmdObj Object as defined for subprocess.call()
- */
- init: function(cmdObj) {
- this._cmdObj = cmdObj;
-
- // create & open pipeListener for stderr, no matter if needed or not
- this.stderrData = Cc[NS_IPCBUFFER_CONTRACTID].createInstance(
- Ci.nsIIPCBuffer);
- this.stderrData.open(-1, true);
-
-
- if (typeof (cmdObj.command) == "string") {
- let localfile = Cc["@mozilla.org/file/local;1"].createInstance(
- Ci.nsILocalFile);
- localfile.initWithPath(cmdObj.command);
- cmdObj._commandFile = localfile.QueryInterface(Ci.nsIFile);
- }
- else {
- cmdObj._commandFile = cmdObj.command;
- }
- if (typeof (cmdObj.arguments) != "object") cmdObj.arguments = [];
- if (typeof (cmdObj.environment) != "object") cmdObj.environment = [];
- if (typeof (cmdObj.workdir) == "string") {
- let localfile= Cc["@mozilla.org/file/local;1"].createInstance(
- Ci.nsILocalFile);
- localfile.initWithPath(cmdObj.workdir);
- cmdObj._cwd = localfile.QueryInterface(Ci.nsIFile);
- }
- else if (typeof (cmdObj.workdir) == "object") {
- cmdObj._cwd = cmdObj.workdir;
- }
- else {
- cmdObj._cwd = null;
- }
-
- this._pipeTransport = Cc[NS_PIPETRANSPORT_CONTRACTID].createInstance(
- Ci.nsIPipeTransport);
- this._pipeTransport.initWithWorkDir(cmdObj._commandFile, cmdObj._cwd,
- Ci.nsIPipeTransport.INHERIT_PROC_ATTRIBS);
-
- this.stdoutListener = null;
- if (typeof(cmdObj.stdout) == "object") {
- // add listener for asynchronous processing of data
- this.stdoutListener = new StdoutStreamListener(cmdObj);
- }
- else {
- this.stdoutListener = Cc[NS_IPCBUFFER_CONTRACTID].createInstance(
- Ci.nsIIPCBuffer);
- this.stdoutListener.open(-1, true);
- }
-
- if (typeof(cmdObj.stderr) == "object" ||
- typeof(cmdObj.onFinished) == "object")
- this.stdoutListener.observe(new OnFinishedListener(this), null);
-
- this._pipeTransport.openPipe(cmdObj.arguments, cmdObj.arguments.length,
- cmdObj.environment, cmdObj.environment.length,
- 0, "", true, cmdObj.mergeStderr ? true : false,
- this.stderrData);
-
- this._pipeTransport.asyncRead(this.stdoutListener, null, 0, -1, 0);
-
- if (typeof(cmdObj.stdin) == "string") {
- this._pipeTransport.writeSync(cmdObj.stdin, cmdObj.stdin.length);
- this._pipeTransport.closeStdin();
- }
- else if (typeof(cmdObj.stdin) == "object") {
- cmdObj.stdin._pipeTransport = this._pipeTransport;
- cmdObj.stdin.startWriting();
- }
- }, // init
-
- /**
- * Wait for the subprocess to complete. This method is blocking.
- */
- wait: function () {
- this._pipeTransport.join();
- },
-
- /**
- * Kill the subprocess
- */
- kill: function() {
- try {
- this._pipeTransport.kill();
- }
- catch(ex) {
- // do nothing
- }
- }
-}; // PipeObj
View
53 ipc/firegpg-ipc/public/Makefile.in
@@ -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 "MPL"); you may not use this file
-# except in compliance with the MPL. You may obtain a copy of
-# the MPL at http://www.mozilla.org/MPL/
-#
-# Software distributed under the MPL is distributed on an "AS
-# IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
-# implied. See the MPL for the specific language governing
-# rights and limitations under the MPL.
-#
-# The Original Code is protoZilla.
-#
-# The Initial Developer of the Original Code is Ramalingam Saravanan.
-# Portions created by Ramalingam Saravanan <svn@xmlterm.org> are
-# Copyright (C) 2001 Ramalingam Saravanan. All Rights Reserved.
-#
-# Contributor(s):
-# Patrick Brunschwig <patrick@mozilla-enigmail.org>
-#
-# 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 = firegpg_ipc
-XPIDL_MODULE = firegpg_ipc
-
-XPIDLSRCS = \
- nsIPipeListener.idl \
- nsIPipeTransport.idl \
- nsIIPCBuffer.idl \
- $(NULL)
-
-include $(topsrcdir)/config/rules.mk
View
122 ipc/firegpg-ipc/public/nsIIPCBuffer.idl
@@ -1,122 +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 "MPL"); you may not use this file
- * except in compliance with the MPL. You may obtain a copy of
- * the MPL at http://www.mozilla.org/MPL/
- *
- * Software distributed under the MPL is distributed on an "AS
- * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
- * implied. See the MPL for the specific language governing
- * rights and limitations under the MPL.
- *
- * The Original Code is protoZilla.
- *
- * The Initial Developer of the Original Code is Ramalingam Saravanan.
- * Portions created by Ramalingam Saravanan <svn@xmlterm.org> are
- * Copyright (C) 2000 Ramalingam Saravanan. All Rights Reserved.
- *
- * Contributor(s):
- * Patrick Brunschwig <patrick@mozilla-enigmail.org>
- *
- * 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 "nsIPipeListener.idl"
-
-interface nsIURI;
-interface nsIRunnable;
-interface nsIRequestObserver;
-
-%{C++
-#define NS_IPCBUFFER_CLASSNAME "IPC Buffer"
-#define NS_IPCBUFFER_CONTRACTID "@getfiregpg.org/ipc/ipc-buffer;1"
-
-#define NS_IPCBUFFER_CID \
-{ /* babce0c1-7ab1-11d4-8f02-a06008948af5 */ \
- 0xbabce0c1, 0x7ab1, 0x11d4, \
-{0x8f, 0x02, 0xa0, 0x60, 0x08, 0x94, 0x8a, 0xf5} }
-
-%}
-
-/* nsIIPCBuffer is an interface to a byte buffer.
- * It is thread-safe, i.e.,it may be called from any thread. It uses a
- * monitor to ensure data integrity.
- */
-
-[scriptable, uuid(babce0c0-7ab1-11d4-8f02-a06008948af5)]
-interface nsIIPCBuffer : nsIPipeListener
-{
- /**
- * Opens byte buffer
- *
- * @param maxBytes maximum number of bytes to be read
- * (maxBytes <= 0 --> unlimited buffer size)
- * @param overflowFile determines if a temporary file should be created
- * if the data to hold in the buffer grows larger than
- * maxBytes. If false and the buffer reached maxBytes
- * then reading will block until data is read from the
- * buffer.
- */
-
- void open(in long maxBytes, in boolean overflowFile);
-
- /**
- * Loads an URI into the console buffer (use instead of the open method)
- *
- * @param aURI URI to be loaded
- * @param maxBytes maximum number of bytes to be read
- * (maxBytes <= 0 --> unlimited buffer size)
- * @param synchronous determines whether to load synchronously
- * (NOTE: This DOESN'T WORK if the input stream operates
- * on the same thread -- reading and writing are
- * both blocking operations)
- * @param observer a request observer (same as if defined via observe())
- * @param ctxt opaque parameter passed to listener methods
- * @param overflowFile determines if a temporary file should be created
- * (see open() for details)
- */
- void openURI(in nsIURI aURI,
- in long maxBytes,
- in boolean synchronous,
- in nsIRequestObserver observer,
- in nsISupports ctxt,
- in boolean overflowFile);
-
- /**
- * Opens an input stream to access buffer data;
- * should be called only after the OnStopRequest call to streamListener.
- * Note: On closing the stream, the buffer will be cleared
- */
- nsIInputStream openInputStream();
-
- /**
- * Returns data from buffer
- * (as a NUL-terminated string)
- */
- string getData();
-
- /**
- * True if onStopRequest method of StreamListener has been invoked
- */
- readonly attribute boolean stopped;
-
- /**
- * Count of total bytes in buffer (or overflow file)
- */
- readonly attribute unsigned long totalBytes;
-};
-
-
-///////////////////////////////////////////////////////////////////////////////
View
114 ipc/firegpg-ipc/public/nsIPipeListener.idl
@@ -1,114 +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 "MPL"); you may not use this file
- * except in compliance with the MPL. You may obtain a copy of
- * the MPL at http://www.mozilla.org/MPL/
- *
- * Software distributed under the MPL is distributed on an "AS
- * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
- * implied. See the MPL for the specific language governing
- * rights and limitations under the MPL.
- *
- * The Original Code is protoZilla.
- *
- * The Initial Developer of the Original Code is Ramalingam Saravanan.
- * Portions created by Ramalingam Saravanan <svn@xmlterm.org> are
- * Copyright (C) 2000 Ramalingam Saravanan. All Rights Reserved.
- *
- * Contributor(s):
- * Patrick Brunschwig <patrick@mozilla-enigmail.org>
- *
- * 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 "nsIStreamListener.idl"
-
-%{C++
-#include "IPCProcess.h"
-
-#define NS_PIPELISTENER_CLASSNAME "IPC PipeListener"
-#define NS_PIPELISTENER_CONTRACTID "@getfiregpg.org/ipc/pipe-listener;1"
-%}
-
-/* nsIPipeListener provides a StreamListener sink.
- * Its implementations should be thread-safe.
- */
-
-[ptr] native IPCFileDescStar(IPCFileDesc);
-
-[scriptable, uuid(babce0d0-7ab1-11d4-8f02-a06008948af5)]
-interface nsIPipeListener : nsIStreamListener
-{
- /**
- * Observes any asynchronous request associated with console.
- * (E.g., when console is used to capture stdout from
- * nsIPipeTransport.execAsync)
- *
- * @param observer The nsIRequestObserver object
- * @param ctxt A user-defined context value that is passed to the
- * observer.
- */
- void observe(in nsIRequestObserver observer, in nsISupports ctxt);
-
- /**
- * true if console pipe thread may be terminated
- */
- readonly attribute boolean joinable;
-
- /**
- * Close input pipe and blocks for console logging thread to terminate,
- * ensuring that all data already written to the console pipe is available
- * for reading from console buffer.
- */
- void join();
-
- /**
- * Shuts down listener (without blocking).
- * Any data already written to the input pipe is discarded.
- */
- void shutdown();
-
- /**
- * Accesses buffer data as a string of arbitrary bytes,
- * including NUL characters.
- */
- void getByteData(out unsigned long count,
- [retval, size_is(count)] out string data);
-
- /**
- * True if data has been lost (i.e., getByteData does not return all data)
- */
- readonly attribute boolean overflowed;
-
- /**
- * Writes a string into the buffer
- */
- void write(in string str);
-
- /**
- * Writes data into the buffer. Data is a string of arbitrary bytes including
- * NUL characters.
- */
- [noscript] void writeBuf(in string buf, in unsigned long count);
-
- /**
- * Returns pipe file descriptor associated with listener.
- */
- [noscript] IPCFileDescStar GetFileDesc();
-
-};
-
-///////////////////////////////////////////////////////////////////////////////
View
294 ipc/firegpg-ipc/public/nsIPipeTransport.idl
@@ -1,294 +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 "MPL"); you may not use this file
- * except in compliance with the MPL. You may obtain a copy of
- * the MPL at http://www.mozilla.org/MPL/
- *
- * Software distributed under the MPL is distributed on an "AS
- * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
- * implied. See the MPL for the specific language governing
- * rights and limitations under the MPL.
- *
- * The Original Code is protoZilla.
- *
- * The Initial Developer of the Original Code is Ramalingam Saravanan.
- * Portions created by Ramalingam Saravanan <svn@xmlterm.org> are
- * Copyright (C) 2000 Ramalingam Saravanan. All Rights Reserved.
- *
- * Contributor(s):
- * Patrick Brunschwig <patrick@mozilla-enigmail.org>
- *
- * 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 "nsIPipeListener.idl"
-#include "nsIProcess.idl"
-
-interface nsIRequest;
-interface nsIFile;
-interface nsIInputStream;
-interface nsIOutputStream;
-interface nsIStreamListener;
-interface nsIPipeTransportHeaders;
-interface nsIPipeTransportListener;
-interface nsIProcess;
-
-%{C++
-
-#include "IPCProcess.h"
-
-#define NS_PIPETRANSPORT_CLASSNAME "Pipe Transport"
-#define NS_PIPETRANSPORT_CONTRACTID "@getfiregpg.org/ipc/pipe-transport;1"
-
-#define NS_PIPETRANSPORT_CID \
-{ /* babce001-7ab1-11d4-8f02-a06008948af5 */ \
- 0xbabce001, 0x7ab1, 0x11d4, \
-{0x8f, 0x02, 0xa0, 0x60, 0x08, 0x94, 0x8a, 0xf5} }
-
-%}
-
-/**
- * The nsIPipeTransport interface executes a file in a new process and
- * communicates with the process using pipes.
- *
- * OWNERSHIP AND THREADING MODEL for nsPipeTransport:
- *
- * nsPipeTransport can be created in any thread with an event queue.
- *
- * nsPipeTransport lives only in the thread that it was created in.
- *
- * nsPipeTransport creates a helper thread object, nsStdoutPoller and retains
- * an owning reference to it. nsStdoutPoller also holds a strong reference
- * to a proxy interface (nsIPipeTransportListener) implemented by
- * nsPipeTransport, which is released when the polling thread terminates.
- *
- * The polling thread terminates when it is "interrupted" by nsPipeTransport or
- * when EOF/error is encountered in reading data from the process STDOUT.
- *
- * The "terminate" method should *always* be called to release the process
- * resources when done.
- *
- * For asynchronous reading, when nsStdoutPoller terminates of its own accord,
- * any stream listener is informed by invoking OnStopRequest.
- * Usually this listener will be the same as the owner of nsPipeTransport.
- * (If the owner initiates the request shutdown by first calling "cancel",
- * then the OnStopRequest method is *not* invoked, because it is assumed
- * that the listener/owner is already aware of the shutdown.)
- *
- */
-[scriptable, uuid(babce000-7ab1-11d4-8f02-a06008948af5)]
-interface nsIPipeTransport : nsIProcess
-{
-
- /**
- * Initializes PipeTransport by executing the specified file using the
- * supplied argument list and environment variables.
- * It is expected that nsIPipeTransport will be embedded in a
- * full-featured channel, which will also act as an async stream
- * observer/listener and forward calls to the actual observer/listener.
- *
- * @param executable executable file
- * @param cwd working directory for the excutable
- * @param startupFlags flags defining how the process should be created
- */
-
- void initWithWorkDir(in nsIFile executable,
- in nsIFile cwd,
- in unsigned long startupFlags);
-
- /**
- * Opens a PipeTransport by executing the specified file using the
- * supplied argument list and environment variables.
- * It is expected that nsIPipeTransport will be embedded in a
- * full-featured channel, which will also act as an async stream
- * observer/listener and forward calls to the actual observer/listener.
- *
- * @param args arguments string array
- * (excluding the executable path itself)
- * @param env environment (variable=value) string array
- * @param timeoutMS timeout (in milliseconds) after which the process
- * at the other end of the pipe can be assumed to be
- * dead
- * (if == 0, a default value, usually an hour, is used)
- * @param killString string to be transmitted to process before it is
- * killed (specify null string, if none)
- * @param noProxy do not use proxy for async callback
- * (must use join to terminate process, in this case)
- * @param mergeStderr merge STDERR with STDOUT
- * @param stderrConsole nsIPipeListener object to capture STDERR (required
- * if mergeStderr is false)
- */
- void openPipe([array, size_is(argCount)] in wstring args,
- in unsigned long argCount,
- [array, size_is(envCount)] in wstring env,
- in unsigned long envCount,
- in unsigned long timeoutMS,
- in string killString,
- in boolean noProxy,
- in boolean mergeStderr,
- in nsIPipeListener stderrConsole);
-
- /**
- * detach process after start
- */
- const long PROCESS_DETACHED = 0x01;
- const long INHERIT_PROC_ATTRIBS = 0x02;
-
- /**
- * Returns stderrConsole object used to capture STDERR by default
- */
- readonly attribute nsIPipeListener stderrConsole;
-
- /**
- * Returns listener object to feed data to STDIN
- * (call to OnStopRequest closes STDIN)
- */
- readonly attribute nsIStreamListener listener;
-
- /**
- * Specifies interface to handle MIME headers read from STDOUT
- */
- attribute nsIPipeTransportHeaders headerProcessor;
-
- /**
- * Controls console logging of STDOUT from process
- */
- attribute boolean loggingEnabled;
-
- /**
- * Open an input stream on this transport.
- *
- * @param offset - read starting at this offset
- * @param count - read this many bytes (pass PRUint32(-1) if unlimited)
- * @param flags - optional transport specific flags
- */
- nsIInputStream openInputStream(in unsigned long offset,
- in unsigned long count,
- in unsigned long flags);
-
- /**
- * Open an output stream on this transport.
- *
- * @param offset - write starting at this offset
- * @param count - write no more than this many bytes (pass PRUint32(-1) if
- * unlimited)
- * @param flags - optional transport specific flags
- */
- nsIOutputStream openOutputStream(in unsigned long offset,
- in unsigned long count,
- in unsigned long flags);
-
- /**
- * Asynchronously read data from the transport.
- *
- * @param listener - notify this listener when data is available
- * @param ctxt - opaque parameter passed to listener methods
- * @param offset - read starting at this offset
- * @param count - read this many bytes (pass PRUint32(-1) if unlimited)
- * @param flags - optional transport specific flags
- */
- nsIRequest asyncRead(in nsIStreamListener listener,
- in nsISupports ctxt,
- in unsigned long offset,
- in unsigned long count,
- in unsigned long flags);
-
- /**
- * Joins STDOUT handling thread (blocking until STDOUT is closed),
- * (Necessary and only works if noProxy is true)
- * The process still needs to be terminated to free resources.
- */
- void join();
-
- /**
- * Terminates process, if active, by closing stdin/stdout/stderr.
- */
- void terminate();
-
- /**
- * Writes string to process STDIN (synchronously)
- * (Note: child process may exit for valid reasons even before
- * the first call to writeSync, causing an an exception to be
- * thrown because STDIN has been closed by the child.)
- */
- void writeSync(in string inputData, in unsigned long inputLength);
-
- /**
- * closes process STDIN (required even if no data is being transmitted)
- */
- void closeStdin();
-
- /**
- * Writes stream data to process STDIN (asynchronously),
- * and close inputStream and STDIN after writing, if requested
- */
- void writeAsync(in nsIInputStream aFromStream,
- in unsigned long aCount,
- in boolean closeAfterWrite);
-
- /**
- * Blocks for output and returns the first line from STDOUT
- * as a string, up to maxChars (=-1 for unlimited) long.
- * NOTE: This method is intended for short output; for longer
- * output, reading using a stream is the better method.
- */
-
- string readLine(in long maxOutputLen);
-
- attribute unsigned long bufferSegmentSize;
- attribute unsigned long bufferMaxSize;
- attribute unsigned long headersMaxSize;
-};
-
-
-/**
- * nsIPipeTransportHeaders is a helper interface to parse MIME headers as
- * specified by RFC 822.
- */
-
-[scriptable, uuid(babce010-7ab1-11d4-8f02-006008948af5)]
-interface nsIPipeTransportHeaders : nsISupports
-{
- /**
- * Calls channel to parse MIME headers, returning content length
- * or -1 for unknown content length.
- * If invalid MIME headers or no channel set, returns error.
- */
- long parseMimeHeaders(in string mimeHeaders, in unsigned long count);
-};
-
-
-/**
- * nsIPipeTransportListener is a helper interface for nsIPipeTransport.
- * It is used to start and stop the listener stream of nsIPipeTransport.
- */
-[scriptable, uuid(babce020-7ab1-11d4-8f02-006008948af5)]
-interface nsIPipeTransportListener : nsIPipeTransportHeaders
-{
- /**
- * Starts listener, and invokes OnStartRequest on listener, if any.
- * NOTE: Should not be called if blocked for synchronous read.
- */
- void startRequest();
-
- /**
- * Stops listener
- */
- void stopRequest(in nsresult status);
-};
-
-
-///////////////////////////////////////////////////////////////////////////////
View
16 ipc/firegpg-ipc/readme.txt
@@ -1,16 +0,0 @@
-Compiling ipccode
-*****************
-
-To compile ipccode, follow these steps:
-1. Compile a complete Firefox build
-2. Copy the ipcode directory into src/mozilla/extensions
-3. cd to src/mozilla/extensions/ipccode
-4. execute: ./makemake -r
-5. cd to @MOZ_OBDIR@/mozilla/extensions/ipccode and execute "make"
-
-Notes
-*****
-makemake cannot handle symbolic links, you need to cd to the real directory
-of your source code.
-makemake tries to read your .mozconfig file to determine @MOZ_OBJDIR@. You can
-alternatively provide your own MOZ_OBJDIR using makemake -o
View
684 ipc/firegpg-ipc/src/IPCProcess.cpp
@@ -1,684 +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 "MPL"); you may not use this file
- * except in compliance with the MPL. You may obtain a copy of
- * the MPL at http://www.mozilla.org/MPL/
- *
- * Software distributed under the MPL is distributed on an "AS
- * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
- * implied. See the MPL for the specific language governing
- * rights and limitations under the MPL.
- *
- * The Original Code is the Netscape Portable Runtime (NSPR).
- *
- * The Initial Developer of the Original Code is Netscape
- * Communications Corporation. Portions created by Netscape are
- * Copyright (C) 1998-2000 Netscape Communications Corporation. All
- * Rights Reserved.
- *
- * Contributor(s):
- * Ramalingam Saravanan <svn@xmlterm.org>
- * Patrick Brunschwig <patrick@mozilla-enigmail.org>
- *
- * 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 "ipc.h"
-#include "IPCProcess.h"
-#include "nsMemory.h"
-
-#ifdef XP_WIN
-#include <windows.h>
-#include <shellapi.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <io.h>
-#include <fcntl.h>
-
-static void IPC_HideConsoleWin32();
-#endif
-
-
-PRProcess* IPC_CreateProcessRedirectedNSPR(const char *path,
- char *const *argv,
- char *const *envp,
- const char *cwd,
- PRFileDesc* std_in,
- PRFileDesc* std_out,
- PRFileDesc* std_err,
- PRBool detach)
-{
-#ifdef XP_WIN
- // Workaround for Win32
- // Hide process console (after creating one, if need be)
- IPC_HideConsoleWin32();
-#endif
-
- PRProcess* process;
- PRProcessAttr *processAttr;
- processAttr = PR_NewProcessAttr();
-
- /* Set current working directory */
- if (cwd)
- PR_ProcessAttrSetCurrentDirectory(processAttr, cwd);
-
- /* Redirect standard I/O for process */
- if (std_in)
- PR_ProcessAttrSetStdioRedirect(processAttr, (PRSpecialFD) 0, std_in);
-
- if (std_out)
- PR_ProcessAttrSetStdioRedirect(processAttr, (PRSpecialFD) 1, std_out);
-
- if (std_err)
- PR_ProcessAttrSetStdioRedirect(processAttr, (PRSpecialFD) 2, std_err);
-
-
- /* Create NSPR process */
- process = PR_CreateProcess(path, argv, envp, processAttr);
-
- if (detach) {
- PR_DetachProcess(process);
- }
-
- return process;
-
-}
-
-PRStatus IPC_CreateInheritablePipeNSPR(PRFileDesc* *readPipe,
- PRFileDesc* *writePipe,
- PRBool readInherit,
- PRBool writeInherit)
-{
- PRStatus status;
-
- //status = PR_NewTCPSocketPair(fd);
- status = PR_CreatePipe(readPipe, writePipe);
- if (status != PR_SUCCESS)
- return status;
-
- // Hack to handle Win32 problem: PR_SetFDInheritable returns error
- // when we try to return off inheritability. However, inheritability is
- // supposed to be off by default, so it shouldn't really matter.
- status = PR_SUCCESS;
-#ifdef XP_WIN
- if (readInherit)
-#endif
- status = PR_SetFDInheritable(*readPipe, readInherit);
- if (status != PR_SUCCESS)
- return status;
-
-#ifdef XP_WIN
- if (writeInherit)
-#endif
- status = PR_SetFDInheritable(*writePipe, writeInherit);
- if (status != PR_SUCCESS)
- return status;
-
- return PR_SUCCESS;
-}
-
-
-#ifdef XP_WIN
-static PRBool gIPCWinConsoleAllocated = PR_FALSE;
-#endif
-
-// Note: it's not necessary to free/close the console, there is (at most) 1
-// console in a parent process
-
-PRStatus IPC_GetProcessIdNSPR(IPCProcess* process, PRInt32 *pid)
-{
- *pid = 0;
-
- if (! process)
- return PR_FAILURE;
-
- struct MYProcess {
- PRUint32 pid;
- };
- MYProcess* ptrProc = (MYProcess *) process;
- *pid = ptrProc->pid;
-
- return PR_SUCCESS;
-}
-
-
-#ifdef XP_WIN
-// Workaround for Win32
-// Try to create a console, if one hasn't already been created
-// (Otherwise each child process creates a console!)
-// and then hide the console.
-// See http://support.microsoft.com/support/kb/articles/q105/3/05.asp
-// and http://support.microsoft.com/support/kb/articles/Q124/1/03.asp
-
-void IPC_HideConsoleWin32()
-{
-
- // AllocConsole and SetConsoleTitle et al. are Windows API functions.
- // See Windows SDK/.../include/WinCon.h, WinBase.h, WinUser.h
-
- if (!gIPCWinConsoleAllocated && ::AllocConsole()) {
- // Set console title
- const char consoleTitle[] = "IPC error console";
- ::SetConsoleTitle(consoleTitle);
-
- // Redirect stderr
- int hCrt = ::_open_osfhandle( (long)::GetStdHandle( STD_ERROR_HANDLE ),
- _O_TEXT );
- if ( hCrt != -1 ) {
- FILE *hf = ::_fdopen(hCrt, "w");
- if ( hf ) {
- *stderr = *hf;
- }
- }
-
- HWND hWnd;
- int iWait;
-
- for (iWait = 0; iWait < 50; iWait++) {
- // Wait for window title to be updated (up to 1 second)
- ::Sleep(20);
-
- // Get console window handle using title
- // (::GetConsoleWindow() not available in win32 prior to Win2K)
-
- hWnd = ::FindWindow(NULL, consoleTitle);
-
- if (hWnd) {
- ::ShowWindow(hWnd, SW_HIDE); // Hide console window
- break;
- }
- }
- }
-
- // Console allocated
- gIPCWinConsoleAllocated = PR_TRUE;
-
-}
-
-#endif /* XP_WIN */
-
-
-#ifdef XP_WIN_IPC
-
-/*
- *
- * Windows specific code adapted from mozilla/xpcom/threads/nsProcessCommon.cpp
- * Out param `wideCmdLine` must be PR_Freed by the caller.
- */
-
-static int assembleCmdLine(char *const *argv, PRUnichar **wideCmdLine)
-{
- char *const *arg;
- char *p, *q, *cmdLine;
- int cmdLineSize;
- int numBackslashes;
- int i;
- int argNeedQuotes;
-
- UINT codePage = CP_UTF8; // the code page to use for the parameter strings
-
- // Find out how large the command line buffer should be.
-
- cmdLineSize = 0;
- for (arg = argv; *arg; arg++) {
-
- // \ and " need to be escaped by a \. In the worst case,
- // every character is a \ or ", so the string of length
- // may double. If we quote an argument, that needs two ".
- // Finally, we need a space between arguments, and
- // a null byte at the end of command line.
-
- cmdLineSize += 2 * strlen(*arg) + // \ and " need to be escaped
- 2+ // we quote every argument
- 1; // space in between, or final null
- }
- p = cmdLine = (char *) PR_MALLOC(cmdLineSize*sizeof(char));
- if (p == NULL) {
- return -1;
- }
-
- for (arg = argv; *arg; arg++) {
- // Add a space to separates the arguments
- if (arg != argv) {
- *p++ = ' ';
- }
- q = *arg;
- numBackslashes = 0;
- argNeedQuotes = 0;
-
- // If the argument contains white space, it needs to be quoted.
- if (strpbrk(*arg, " \f\n\r\t\v")) {
- argNeedQuotes = 1;
- }
-
- if (argNeedQuotes) {
- *p++ = '"';
- }
- while (*q) {
- if (*q == '\\') {
- numBackslashes++;
- q++;
- } else if (*q == '"') {
- if (numBackslashes) {
-
- // Double the backslashes since they are followed
- // by a quote
- for (i = 0; i < 2 * numBackslashes; i++) {
- *p++ = '\\';
- }
- numBackslashes = 0;
- }
- // To escape the quote
- *p++ = '\\';
- *p++ = *q++;
- } else {
- if (numBackslashes) {
-
- // Backslashes are not followed by a quote, so
- // don't need to double the backslashes.
-
- for (i = 0; i < numBackslashes; i++) {
- *p++ = '\\';
- }
- numBackslashes = 0;
- }
- *p++ = *q++;
- }
- }
-
- // Now we are at the end of this argument
- if (numBackslashes) {
-
- // Double the backslashes if we have a quote string
- // delimiter at the end.
-
- if (argNeedQuotes) {
- numBackslashes *= 2;
- }
- for (i = 0; i < numBackslashes; i++) {
- *p++ = '\\';
- }
- }
- if (argNeedQuotes) {