New XML-RPC Client component.

_NOT PART OF THE BUILD_


git-svn-id: svn://10.0.0.236/trunk@68360 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
mj%digicool.com 2000-05-05 06:06:34 +00:00
parent c50a812859
commit 1d76c60c78
13 changed files with 2084 additions and 0 deletions

View File

@ -0,0 +1,32 @@
#
# 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 XML-RPC Client and XPCOM Dictionary components.
#
# The Initial Developer of the Original Code is Digital Creations 2, Inc.
# Portions created by Digital Creations 2, Inc. are Copyright (C) 2000 Digital
# Creations 2, Inc. All Rights Reserved.
#
# Contributor(s): Martijn Pieters <mj@digicool.com> (original author)
#
DEPTH = ../..
topsrcdir = @top_srcdir@
srcdir = @srcdir@
VPATH = @srcdir@
include $(DEPTH)/config/autoconf.mk
DIRS = \
idl \
src \
$(NULL)
include $(topsrcdir)/config/rules.mk

View File

@ -0,0 +1,16 @@
# 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 XML-RPC Client and XPCOM Dictionary components.
#
# The Initial Developer of the Original Code is Digital Creations 2, Inc.
# Portions created by Digital Creations 2, Inc. are Copyright (C) 2000 Digital
# Creations 2, Inc. All Rights Reserved.
#
# Contributor(s): Martijn Pieters <mj@digicool.com> (original author)
#
nsIDictionary.idl
nsIXmlRpcClient.idl
nsIXmlRpcClientListener.idl

View File

@ -0,0 +1,35 @@
#
# 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 XML-RPC Client and XPCOM Dictionary components.
#
# The Initial Developer of the Original Code is Digital Creations 2, Inc.
# Portions created by Digital Creations 2, Inc. are Copyright (C) 2000 Digital
# Creations 2, Inc. All Rights Reserved.
#
# Contributor(s): Martijn Pieters <mj@digicool.com> (original author)
#
DEPTH = ../../..
topsrcdir = @top_srcdir@
srcdir = @srcdir@
VPATH = @srcdir@
include $(DEPTH)/config/autoconf.mk
MODULE = xml-rpc
XPIDLSRCS = \
nsIDictionary.idl \
nsIXmlRpcClientListener.idl \
nsIXmlRpcClient.idl \
$(NULL)
include $(topsrcdir)/config/rules.mk

View File

@ -0,0 +1,30 @@
#
# 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 XML-RPC Client and XPCOM Dictionary components.
#
# The Initial Developer of the Original Code is Digital Creations 2, Inc.
# Portions created by Digital Creations 2, Inc. are Copyright (C) 2000 Digital
# Creations 2, Inc. All Rights Reserved.
#
# Contributor(s): Martijn Pieters <mj@digicool.com> (original author)
#
MODULE = xml-rpc
DEPTH = ..\..\..
XPIDLSRCS = \
.\nsIDictionary.idl \
.\nsIXmlRpcClientListener.idl \
.\nsIXmlRpcClient.idl \
$(NULL)
include <$(DEPTH)/config/rules.mak>

View File

@ -0,0 +1,83 @@
/*
* 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 XPCOM Dictionary.
*
* The Initial Developer of the Original Code is Digital Creations 2, Inc.
* Portions created by Digital Creations 2, Inc. are Copyright (C) 2000 Digital
* Creations 2, Inc. All Rights Reserved.
*
* Contributor(s): Martijn Pieters <mj@digicool.com> (original author)
*/
/*
* Simple dictionary implementation.
* Version: $Revision: 1.1 $
*
* $Id: nsIDictionary.idl,v 1.1 2000-05-05 06:06:31 mj%digicool.com Exp $
*/
#include "nsISupports.idl"
/**
* A simple mutable table of objects, accessed by key.
*/
[scriptable, uuid(1dd0cb45-aea3-4a52-8b29-01429a542863)]
interface nsIDictionary: nsISupports {
/**
* Check if a given key is present in the dictionary.
*
* @param key Key to check for
* @return true if present, false if absent.
*/
boolean hasKey(in string key);
/**
* Retrieve all keys in the dictionary.
*
* @return array of all keys, unsorted.
*/
void getKeys(out PRUint32 count,
[retval, array, size_is(count)] out string keys);
/**
* Find the value indicated by the key.
*
* @param key The lookup key indicating the value.
* @return Value indicated by key. If the key doesn't exist,
* NS_ERROR_FAILURE will be returned.
*/
nsISupports getValue(in string key);
/**
* Add the key-value pair to the dictionary.
* If the key is already present, replace the old value
* with the new.
*
* @param key The key by which the value can be accessed
* @param value The value to be stored.
*/
void setValue(in string key, in nsISupports value);
/**
* Delete the indicated key-value pair.
*
* @param key The key indicating the pair to be removed.
* @return The removed value. If the key doesn't exist,
* NS_ERROR_FAILURE will be returned.
*/
nsISupports deleteValue(in string key);
/**
* Delete all key-value pairs from the dictionary.
*/
void clear();
};
// vim:sw=4:sr:sta:et:sts:

View File

@ -0,0 +1,160 @@
/*
* 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 XML-RPC Client component.
*
* The Initial Developer of the Original Code is Digital Creations 2, Inc.
* Portions created by Digital Creations 2, Inc. are Copyright (C) 2000 Digital
* Creations 2, Inc. All Rights Reserved.
*
* Contributor(s): Martijn Pieters <mj@digicool.com> (original author)
*/
/*
* XPCOM XML-RPC Client, interface definition.
* Version: $Revision: 1.1 $
*
* $Id: nsIXmlRpcClient.idl,v 1.1 2000-05-05 06:06:31 mj%digicool.com Exp $
*/
#include "nsISupports.idl"
#include "nsIURL.idl"
#include "nsIXmlRpcClientListener.idl"
// forward decl.
interface nsIXmlRpcFault;
/**
* Simple XML-RPC client interface.
*/
[scriptable, uuid(37127241-1e6e-46aa-ba87-601d41bb47df)]
interface nsIXmlRpcClient: nsISupports {
/**
* Set server URL. Call this before using this object.
*
* @param serverURL URL of server side object on which methods should
* be called.
*/
void init(in string serverURL);
/**
* The URL of the XML-RPC server
*/
readonly attribute nsIURL serverURL;
/**
* Call remote method methodName with given arguments.
*
* Supported arguments are:
* nsISupportsPRUint8, nsISupportsPRUint16,
* nsISupportsPRInt16, nsISupportsPRInt32: <i4>
* nsISupportsPRBool: <boolean>
* nsISupportsChar, nsISupportsString: <string>
* nsISupportsFloat, nsISupportsDouble: <double>
* nsISupportsPRTime: <dateTime.iso8601>
* nsIInputStream: <base64>
* nsISupportsArray: <array>
* nsIDictionary: <struct>
*
* Note that both nsISupportsArray and nsIDictionary can only hold any of
* the supported input types.
*
* Return value will be converted as follows:
* <i4> or <int>: nsISupportsPRInt32
* <boolean>: nsISupportsPRBool
* <string>: nsISupportsString
* <double>: nsISupportsDouble
* <dateTime.iso8601>: nsISupportsPRTime
* <base64>: nsISupportsString
* <array>: nsISupportsArray
* <struct>: nsIDictionary
*
* <fault>s (server side errors) are indicated by returning
* NS_ERROR_FAILURE. Via nsIXPConnect::GetPendingException()->data a
* nsIXmlRpcFault object can be retreieved with more information on the
* fault.
*
* @param methodName Remote method to call.
* @param arguments Array of arguments to pass to remote method.
* @return Return value of remote method.
*/
nsISupports call(in string methodName,
[array, size_is(count)] in nsISupports arguments, in PRUint32 count);
/**
* The asynchronous version of call.
*
* @param listener A nsIXmlRpcClientListener that will get notified
* of XML-RPC events.
* @param context A context to be passed on to the listener.
* @param methodName Remote method to call.
* @param arguments Array of arguments to pass to remote method.
* @return Return value of remote method.
*/
void asyncCall(in nsIXmlRpcClientListener listener, in nsISupports ctxt,
in string methodName,
[array, size_is(count)] in nsISupports arguments, in PRUint32 count);
/**
* Wether or not a call is in progress
*/
readonly attribute boolean inProgress;
/**
* The most recent XML-RPC fault from returned from this server.
* null if the last call didn't return an XML-RPC fault.
*/
readonly attribute nsIXmlRpcFault fault;
/**
* The most recent XML-RPC call result returned from this server.
* null if the last call didn't return a valid result
*/
readonly attribute nsISupports result;
/**
* The most recent HTTP status code returned from this server
* null if the server was unreachable or not yet contacted.
*/
readonly attribute unsigned long responseStatus;
readonly attribute unsigned long responseString;
/**
* Convenience: return the correct nsISupportsPrimitive for a given XML-RPC
* type, or nsISupportsArray or nsIDictionary. 'base64' isn't supported.
*
* @param type One of the listed constants.
* @return Return an appropriate XPCOM object.
*/
nsISupports createType(in unsigned long type);
const unsigned long INT = 1; // nsISupportsPRInt32
const unsigned long BOOLEAN = 2; // nsISupportsPRBool
const unsigned long STRING = 3; // nsISupportsString
const unsigned long DOUBLE = 4; // nsISupportsDouble
const unsigned long DATETIME = 5; // nsISupportsPRTime
const unsigned long ARRAY = 6; // nsISupportsArray
const unsigned long STRUCT = 7; // nsIDictionary
};
/**
* An XML-RPC exception.
* XML-RPC server fault codes are returned wrapped in this Access via
* nsIXPConnect::GetPendingException()->data
*/
[scriptable, uuid(691cb864-0a7e-448c-98ee-4a7f359cf145)]
interface nsIXmlRpcFault: nsISupports {
readonly attribute PRInt32 faultCode;
readonly attribute string faultString;
void init(in PRInt32 faultCode, in string faultString);
string toString();
};
// vim:sw=4:sr:sta:et:sts:

View File

@ -0,0 +1,66 @@
/*
* 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 XML-RPC Client component.
*
* The Initial Developer of the Original Code is Digital Creations 2, Inc.
* Portions created by Digital Creations 2, Inc. are Copyright (C) 2000 Digital
* Creations 2, Inc. All Rights Reserved.
*
* Contributor(s): Martijn Pieters <mj@digicool.com> (original author)
*/
/*
* XPCOM XML-RPC Client listener, interface definition.
* Version: $Revision: 1.1 $
*
* $Id: nsIXmlRpcClientListener.idl,v 1.1 2000-05-05 06:06:31 mj%digicool.com Exp $
*/
#include "nsISupports.idl"
// forward decl.
interface nsIXmlRpcClient;
interface nsIXmlRpcFault;
[scriptable, uuid(27e60cd8-6d63-4d87-b7d1-82c09e0c7363)]
interface nsIXmlRpcClientListener: nsISupports {
/**
* Called when XML-RPC call has succeeded.
*
* @param client The originating XML-RPC client.
* @param context The context passed in to the asyncCall method.
* @param result The result of the XML-RPC call.
*/
void onResult(in nsIXmlRpcClient client, in nsISupports ctxt,
in nsISupports result);
/**
* Called when the XML-RPC server returned a Fault
*
* @param client The originating XML-RPC client.
* @param context The context passed in to the asyncCall method.
* @param fault The XML-RPC fault as returned by the server.
*/
void onFault(in nsIXmlRpcClient client, in nsISupports ctxt,
in nsIXmlRpcFault fault);
/**
* Called when a transport or other error occurs.
*
* @param client The originating XML-RPC client.
* @param context The context passed in to the asyncCall method.
* @param status The status code of the error.
* @param errorMsg A human readable error message.
*/
void onError(in nsIXmlRpcClient client, in nsISupports ctxt,
in nsresult status, in wstring errorMsg);
};
// vim:sw=4:sr:sta:et:sts:

View File

@ -0,0 +1,27 @@
#
# 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 XML-RPC Client and XPCOM Dictionary components.
#
# The Initial Developer of the Original Code is Digital Creations 2, Inc.
# Portions created by Digital Creations 2, Inc. are Copyright (C) 2000 Digital
# Creations 2, Inc. All Rights Reserved.
#
# Contributor(s): Martijn Pieters <mj@digicool.com> (original author)
#
DEPTH =..\..
DIRS = \
idl \
src \
$(NULL)
include <$(DEPTH)\config\rules.mak>

View File

@ -0,0 +1,15 @@
# 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 XML-RPC Client and XPCOM Dictionary components.
#
# The Initial Developer of the Original Code is Digital Creations 2, Inc.
# Portions created by Digital Creations 2, Inc. are Copyright (C) 2000 Digital
# Creations 2, Inc. All Rights Reserved.
#
# Contributor(s): Martijn Pieters <mj@digicool.com> (original author)
#
nsDictionary.js
nsXmlRpcClient.js

View File

@ -0,0 +1,33 @@
#
# 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 XML-RPC Client and XPCOM Dictionary components.
#
# The Initial Developer of the Original Code is Digital Creations 2, Inc.
# Portions created by Digital Creations 2, Inc. are Copyright (C) 2000 Digital
# Creations 2, Inc. All Rights Reserved.
#
# Contributor(s): Martijn Pieters <mj@digicool.com> (original author)
#
DEPTH = ../../..
topsrcdir = @top_srcdir@
srcdir = @srcdir@
VPATH = @srcdir@
include $(DEPTH)/config/autoconf.mk
JSFILES = \
$(srcdir)/nsDictionary.js \
$(srcdir)/nsXmlRpcClient.js \
include $(topsrcdir)/config/rules.mk
install::
$(INSTALL) $(JSFILES) $(DIST)/bin/components

View File

@ -0,0 +1,29 @@
#
# 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 XML-RPC Client and XPCOM Dictionary components.
#
# The Initial Developer of the Original Code is Digital Creations 2, Inc.
# Portions created by Digital Creations 2, Inc. are Copyright (C) 2000 Digital
# Creations 2, Inc. All Rights Reserved.
#
# Contributor(s): Martijn Pieters <mj@digicool.com> (original author)
#
DEPTH =..\..\..
JSFILES = \
.\nsDictionary.js \
.\nsXmlRpcClient.js \
$(NULL)
include <$(DEPTH)\config\rules.mak>
install::
$(MAKE_INSTALL) $(JSFILES) $(DIST)\bin\components

View File

@ -0,0 +1,125 @@
/*
* 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 XPCOM Dictionary.
*
* The Initial Developer of the Original Code is Digital Creations 2, Inc.
* Portions created by Digital Creations 2, Inc. are Copyright (C) 2000 Digital
* Creations 2, Inc. All Rights Reserved.
*
* Contributor(s): Martijn Pieters <mj@digicool.com> (original author)
*/
/*
* nsDictionary XPCOM component
* Version: $Revision: 1.1 $
*
* $Id: nsDictionary.js,v 1.1 2000-05-05 06:06:34 mj%digicool.com Exp $
*/
/*
* Constants
*/
const DICTIONARY_PROGID = 'mozilla.dictionary.1';
const DICTIONARY_CID = Components.ID('{1dd0cb45-aea3-4a52-8b29-01429a542863}');
const DICTIONARY_IID = Components.interfaces.nsIDictionary;
/*
* Class definitions
*/
/* The nsDictionary class constructor. */
function nsDictionary() {
this.hash = {};
}
/* the nsDictionary class def */
nsDictionary.prototype= {
hasKey: function(key) { return this.hash.hasOwnProperty(key) },
getKeys: function(count) {
var asKeys = new Array();
for (sKey in this.hash) asKeys.push(sKey);
count.value = asKeys.length;
return asKeys;
},
getValue: function(key) {
if (!this.hasKey(key))
throw Components.Exception("Key doesn't exist");
return this.hash[key];
},
setValue: function(key, value) { this.hash[key] = value; },
deleteValue: function(key) {
if (!this.hasKey(key))
throw Components.Exception("Key doesn't exist");
var oOld = this.getValue(key);
delete this.hash[key];
return oOld;
},
clear: function() { this.hash = {}; },
QueryInterface: function(iid) {
if (!iid.equals(Components.interfaces.nsISupports) &&
!iid.equals(DICTIONARY_IID))
throw Components.results.NS_ERROR_NO_INTERFACE;
return this;
}
};
/*
* Objects
*/
/* nsDictionary Module (for XPCOM registration) */
var nsDictionaryModule = {
registerSelf: function(compMgr, fileSpec, location, type) {
compMgr.registerComponentWithType(DICTIONARY_CID,
"nsDictionary JS component", DICTIONARY_PROGID, fileSpec, location,
true, true, type);
},
getClassObject: function(compMgr, cid, iid) {
if (!cid.equals(DICTIONARY_CID))
throw Components.results.NS_ERROR_NO_INTERFACE;
if (!iid.equals(Components.interfaces.nsIFactory))
throw Components.results.NS_ERROR_NOT_IMPLEMENTED;
return nsDictionaryFactory;
},
canUnload: function(compMgr) { return true; }
};
/* nsDictionary Class Factory */
var nsDictionaryFactory = {
CreateInstance: function(outer, iid) {
if (outer != null)
throw Components.results.NS_ERROR_NO_AGGREGATION;
if (!iid.equals(DICTIONARY_IID) &&
!iid.equals(Components.interfaces.nsISupports))
throw Components.results.NS_ERROR_INVALID_ARG;
return new nsDictionary();
}
}
/*
* Functions
*/
/* module initialisation */
function NSGetModule(comMgr, fileSpec) { return nsDictionaryModule; }
// vim:sw=4:sr:sta:et:sts:

File diff suppressed because it is too large Load Diff