Compare commits

..

103 Commits

Author SHA1 Message Date
rayw%netscape.com
102abfaf95 Updated the list of IDL files.
git-svn-id: svn://10.0.0.236/branches/SOAP_20010403_BRANCH@109128 18797224-902f-48f8-a5cc-f745e15eee43
2001-11-28 10:13:32 +00:00
rayw%netscape.com
303b94b230 Updates.
git-svn-id: svn://10.0.0.236/branches/SOAP_20010403_BRANCH@109127 18797224-902f-48f8-a5cc-f745e15eee43
2001-11-28 10:09:30 +00:00
rayw%netscape.com
a214bbc93b More fixes for soap stuff.
git-svn-id: svn://10.0.0.236/branches/SOAP_20010403_BRANCH@108927 18797224-902f-48f8-a5cc-f745e15eee43
2001-11-26 22:31:43 +00:00
rayw%netscape.com
4a35edca7c Miscellaneous fixes to make shared library load.
git-svn-id: svn://10.0.0.236/branches/SOAP_20010403_BRANCH@108864 18797224-902f-48f8-a5cc-f745e15eee43
2001-11-24 23:55:25 +00:00
rayw%netscape.com
84c4f735c8 Fixed more problems with build.
git-svn-id: svn://10.0.0.236/branches/SOAP_20010403_BRANCH@108862 18797224-902f-48f8-a5cc-f745e15eee43
2001-11-24 22:39:29 +00:00
rayw%netscape.com
ede731b482 Fixes to make it added in build on Linux
git-svn-id: svn://10.0.0.236/branches/SOAP_20010403_BRANCH@108857 18797224-902f-48f8-a5cc-f745e15eee43
2001-11-24 16:36:39 +00:00
rayw%netscape.com
5189d96611 Added JS initializer using new functionality.
git-svn-id: svn://10.0.0.236/branches/SOAP_20010403_BRANCH@108843 18797224-902f-48f8-a5cc-f745e15eee43
2001-11-23 19:03:32 +00:00
rayw%netscape.com
3c9c87d3cd Updated http transport.
git-svn-id: svn://10.0.0.236/branches/SOAP_20010403_BRANCH@108841 18797224-902f-48f8-a5cc-f745e15eee43
2001-11-23 17:22:02 +00:00
rayw%netscape.com
abc647b7bf Eliminate unused JS IDL.
git-svn-id: svn://10.0.0.236/branches/SOAP_20010403_BRANCH@108836 18797224-902f-48f8-a5cc-f745e15eee43
2001-11-23 14:42:04 +00:00
rayw%netscape.com
514deaf34b Eliminate unused IDL.
git-svn-id: svn://10.0.0.236/branches/SOAP_20010403_BRANCH@108835 18797224-902f-48f8-a5cc-f745e15eee43
2001-11-23 14:40:43 +00:00
rayw%netscape.com
a0bbdbe2d9 Get the element namespace and name before looking it up. Also, as a last
effort to identify the type, if the namespaceURI belongs to the SOAP
encoding, then compute the type from that and try to look it up.


git-svn-id: svn://10.0.0.236/branches/SOAP_20010403_BRANCH@108834 18797224-902f-48f8-a5cc-f745e15eee43
2001-11-23 14:39:21 +00:00
rayw%netscape.com
0945394e50 Eliminated need for encoding contractID, made all registered services
available as styles in the default encoding, and fixed to create
services.


git-svn-id: svn://10.0.0.236/branches/SOAP_20010403_BRANCH@108824 18797224-902f-48f8-a5cc-f745e15eee43
2001-11-22 23:14:03 +00:00
rayw%netscape.com
5e6cfecab1 Fixed type lookup on decoders with no explicit type.
git-svn-id: svn://10.0.0.236/branches/SOAP_20010403_BRANCH@108823 18797224-902f-48f8-a5cc-f745e15eee43
2001-11-22 22:40:47 +00:00
rayw%netscape.com
6e8995843f Added contract ID for default encoder.
git-svn-id: svn://10.0.0.236/branches/SOAP_20010403_BRANCH@108814 18797224-902f-48f8-a5cc-f745e15eee43
2001-11-22 18:50:56 +00:00
rayw%netscape.com
fb1f129a33 Eliminated JS stuff.
git-svn-id: svn://10.0.0.236/branches/SOAP_20010403_BRANCH@108812 18797224-902f-48f8-a5cc-f745e15eee43
2001-11-22 18:41:10 +00:00
rayw%netscape.com
c59d8f9d70 Eliminated dead code.
git-svn-id: svn://10.0.0.236/branches/SOAP_20010403_BRANCH@108811 18797224-902f-48f8-a5cc-f745e15eee43
2001-11-22 18:22:54 +00:00
rayw%netscape.com
d507f13f1e More fixes in encoders.
git-svn-id: svn://10.0.0.236/branches/SOAP_20010403_BRANCH@108810 18797224-902f-48f8-a5cc-f745e15eee43
2001-11-22 18:19:17 +00:00
rayw%netscape.com
981450bd1e More progress on encoding / decoding.
git-svn-id: svn://10.0.0.236/branches/SOAP_20010403_BRANCH@108808 18797224-902f-48f8-a5cc-f745e15eee43
2001-11-22 17:10:16 +00:00
rayw%netscape.com
c8325f0bab A few more decoders.
git-svn-id: svn://10.0.0.236/branches/SOAP_20010403_BRANCH@108795 18797224-902f-48f8-a5cc-f745e15eee43
2001-11-22 05:14:19 +00:00
rayw%netscape.com
cdff0f18b7 Some basic encoders and decoders there.
git-svn-id: svn://10.0.0.236/branches/SOAP_20010403_BRANCH@108787 18797224-902f-48f8-a5cc-f745e15eee43
2001-11-22 03:11:45 +00:00
rayw%netscape.com
aa259d79a4 Fixed argument handling.
git-svn-id: svn://10.0.0.236/branches/SOAP_20010403_BRANCH@108717 18797224-902f-48f8-a5cc-f745e15eee43
2001-11-21 20:42:02 +00:00
rayw%netscape.com
d5313c3c3c More fixes for changing includes.
git-svn-id: svn://10.0.0.236/branches/SOAP_20010403_BRANCH@108714 18797224-902f-48f8-a5cc-f745e15eee43
2001-11-21 19:46:23 +00:00
rayw%netscape.com
760ef56127 The updated version of several implementations to use variants.
The Serializer / Deserializer is still undefined.


git-svn-id: svn://10.0.0.236/branches/SOAP_20010403_BRANCH@108199 18797224-902f-48f8-a5cc-f745e15eee43
2001-11-15 22:55:34 +00:00
rayw%netscape.com
668c500732 Changes to SOAP APIs to use variants. On branch, not part of
default build.


git-svn-id: svn://10.0.0.236/branches/SOAP_20010403_BRANCH@108198 18797224-902f-48f8-a5cc-f745e15eee43
2001-11-15 22:54:38 +00:00
rayw%netscape.com
9b3e0d9b4a Changes found on laptop
git-svn-id: svn://10.0.0.236/branches/SOAP_20010403_BRANCH@106042 18797224-902f-48f8-a5cc-f745e15eee43
2001-10-23 11:47:58 +00:00
rayw%netscape.com
d08dfe2340 Temporary fixes to string calls until variant is used.
git-svn-id: svn://10.0.0.236/branches/SOAP_20010403_BRANCH@106040 18797224-902f-48f8-a5cc-f745e15eee43
2001-10-23 11:15:00 +00:00
rayw%netscape.com
cdb804758f Renamed TypeRegistry to encodingRegistry and changed the arguments to
encode and decode (yet again) to be closer to what they need to be like
in a world of variants and schema.


git-svn-id: svn://10.0.0.236/branches/SOAP_20010403_BRANCH@102035 18797224-902f-48f8-a5cc-f745e15eee43
2001-08-30 20:37:25 +00:00
rayw%netscape.com
532b55f3a2 Broke out schema namespace URI from schema type
git-svn-id: svn://10.0.0.236/branches/SOAP_20010403_BRANCH@101982 18797224-902f-48f8-a5cc-f745e15eee43
2001-08-29 22:32:23 +00:00
rayw%netscape.com
2e5f028235 Changed the abstraction for encoders to not rely on message.
git-svn-id: svn://10.0.0.236/branches/SOAP_20010403_BRANCH@101966 18797224-902f-48f8-a5cc-f745e15eee43
2001-08-29 21:03:38 +00:00
rayw%netscape.com
d6b1f0b24b Renaming IDs to types.
git-svn-id: svn://10.0.0.236/branches/SOAP_20010403_BRANCH@101927 18797224-902f-48f8-a5cc-f745e15eee43
2001-08-29 01:21:59 +00:00
rayw%netscape.com
0b71d52a13 changed signatures of encoding / decoding.
git-svn-id: svn://10.0.0.236/branches/SOAP_20010403_BRANCH@101926 18797224-902f-48f8-a5cc-f745e15eee43
2001-08-29 01:09:21 +00:00
rayw%netscape.com
c4e2131b79 Added back changes which were lost, byte -> char.
Renamed marshaller -> encoder unmarshaller -> decoder.


git-svn-id: svn://10.0.0.236/branches/SOAP_20010403_BRANCH@101920 18797224-902f-48f8-a5cc-f745e15eee43
2001-08-28 23:05:32 +00:00
rayw%netscape.com
d3497e2e42 Eliminated recent bit rot related to elimination of a macro.
git-svn-id: svn://10.0.0.236/branches/SOAP_20010403_BRANCH@100672 18797224-902f-48f8-a5cc-f745e15eee43
2001-08-09 20:29:59 +00:00
rayw%netscape.com
e2087f1048 Renamed types for less confusion, use PRInt16 instead of char.
git-svn-id: svn://10.0.0.236/branches/SOAP_20010403_BRANCH@99211 18797224-902f-48f8-a5cc-f745e15eee43
2001-07-13 20:28:41 +00:00
rayw%netscape.com
945019d1be More progress on marshallers of primative types.
git-svn-id: svn://10.0.0.236/branches/SOAP_20010403_BRANCH@99205 18797224-902f-48f8-a5cc-f745e15eee43
2001-07-13 19:55:28 +00:00
rayw%netscape.com
c23915b75e Fixed signatures of marshaller and unmarshaller to be more precise.
git-svn-id: svn://10.0.0.236/branches/SOAP_20010403_BRANCH@99148 18797224-902f-48f8-a5cc-f745e15eee43
2001-07-13 00:39:11 +00:00
rayw%netscape.com
05c64c1c84 Better dispatching through TypeRegistry by type.
git-svn-id: svn://10.0.0.236/branches/SOAP_20010403_BRANCH@99143 18797224-902f-48f8-a5cc-f745e15eee43
2001-07-12 23:15:30 +00:00
rayw%netscape.com
f5eacca3bf Added prefix reverse lookup method per level 2.
git-svn-id: svn://10.0.0.236/branches/SOAP_20010403_BRANCH@99138 18797224-902f-48f8-a5cc-f745e15eee43
2001-07-12 21:07:03 +00:00
rayw%netscape.com
063b93702c forgot to increment iterators when comparing strings.
git-svn-id: svn://10.0.0.236/branches/SOAP_20010403_BRANCH@99133 18797224-902f-48f8-a5cc-f745e15eee43
2001-07-12 18:54:17 +00:00
rayw%netscape.com
f859df79cf Cleaned up and implemented QName to UName translation.
git-svn-id: svn://10.0.0.236/branches/SOAP_20010403_BRANCH@99132 18797224-902f-48f8-a5cc-f745e15eee43
2001-07-12 18:50:25 +00:00
rayw%netscape.com
4298e43fe6 Added StartsWith convenience string function.
git-svn-id: svn://10.0.0.236/branches/SOAP_20010403_BRANCH@99129 18797224-902f-48f8-a5cc-f745e15eee43
2001-07-12 17:51:43 +00:00
rayw%netscape.com
8290529258 Added scope argument for marshalling to provide some context in DOM case.
git-svn-id: svn://10.0.0.236/branches/SOAP_20010403_BRANCH@99128 18797224-902f-48f8-a5cc-f745e15eee43
2001-07-12 16:24:28 +00:00
rayw%netscape.com
d4c9b26f98 Missing error test.
git-svn-id: svn://10.0.0.236/branches/SOAP_20010403_BRANCH@98857 18797224-902f-48f8-a5cc-f745e15eee43
2001-07-07 02:29:29 +00:00
rayw%netscape.com
e3fbe1306f Small fix.
git-svn-id: svn://10.0.0.236/branches/SOAP_20010403_BRANCH@98855 18797224-902f-48f8-a5cc-f745e15eee43
2001-07-07 01:47:50 +00:00
rayw%netscape.com
c38912432f Added much fancier unwrapping of wrapped natives.
git-svn-id: svn://10.0.0.236/branches/SOAP_20010403_BRANCH@98854 18797224-902f-48f8-a5cc-f745e15eee43
2001-07-07 01:43:59 +00:00
rayw%netscape.com
5e99220d9a Wrap native objects that have no other JS type.
git-svn-id: svn://10.0.0.236/branches/SOAP_20010403_BRANCH@98844 18797224-902f-48f8-a5cc-f745e15eee43
2001-07-07 00:31:31 +00:00
rayw%netscape.com
f970f5fa83 Make Javascript value property automatically adapt literal nodes.
git-svn-id: svn://10.0.0.236/branches/SOAP_20010403_BRANCH@98817 18797224-902f-48f8-a5cc-f745e15eee43
2001-07-06 16:38:45 +00:00
rayw%netscape.com
5997698812 Added reverse resolution of namespaces (no actual method, yet.)
git-svn-id: svn://10.0.0.236/branches/SOAP_20010403_BRANCH@98759 18797224-902f-48f8-a5cc-f745e15eee43
2001-07-06 01:32:11 +00:00
rayw%netscape.com
3cbdb694bf Lots of fixes.
git-svn-id: svn://10.0.0.236/branches/SOAP_20010403_BRANCH@98740 18797224-902f-48f8-a5cc-f745e15eee43
2001-07-05 23:50:17 +00:00
rayw%netscape.com
87a6f32dd2 Added actorURI to parameter.
git-svn-id: svn://10.0.0.236/branches/SOAP_20010403_BRANCH@98692 18797224-902f-48f8-a5cc-f745e15eee43
2001-07-05 19:18:34 +00:00
rayw%netscape.com
3767a96323 Eliminated header.
git-svn-id: svn://10.0.0.236/branches/SOAP_20010403_BRANCH@98691 18797224-902f-48f8-a5cc-f745e15eee43
2001-07-05 19:12:54 +00:00
rayw%netscape.com
2833b5643a Added a header object to encapsulate headers.
git-svn-id: svn://10.0.0.236/branches/SOAP_20010403_BRANCH@98689 18797224-902f-48f8-a5cc-f745e15eee43
2001-07-05 18:51:13 +00:00
rayw%netscape.com
36873e3a8a Supplied missing setAsStruct.
git-svn-id: svn://10.0.0.236/branches/SOAP_20010403_BRANCH@98674 18797224-902f-48f8-a5cc-f745e15eee43
2001-07-05 17:04:14 +00:00
rayw%netscape.com
8038aa47fc Eliminated #iid type of SOAP parameter.
git-svn-id: svn://10.0.0.236/branches/SOAP_20010403_BRANCH@98673 18797224-902f-48f8-a5cc-f745e15eee43
2001-07-05 16:38:02 +00:00
rayw%netscape.com
1b8fa049b7 Handled some extra cases better.
git-svn-id: svn://10.0.0.236/branches/SOAP_20010403_BRANCH@98654 18797224-902f-48f8-a5cc-f745e15eee43
2001-07-04 20:25:12 +00:00
rayw%netscape.com
9b232ccf63 Reverted js type to be struct type.
git-svn-id: svn://10.0.0.236/branches/SOAP_20010403_BRANCH@98653 18797224-902f-48f8-a5cc-f745e15eee43
2001-07-04 19:53:12 +00:00
rayw%netscape.com
2ed2a24a15 Minor fixes from code review.
git-svn-id: svn://10.0.0.236/branches/SOAP_20010403_BRANCH@98644 18797224-902f-48f8-a5cc-f745e15eee43
2001-07-04 18:51:24 +00:00
rayw%netscape.com
fa3afd301e Added schemaID to marshalling calls.
git-svn-id: svn://10.0.0.236/branches/SOAP_20010403_BRANCH@98597 18797224-902f-48f8-a5cc-f745e15eee43
2001-07-04 00:55:00 +00:00
rayw%netscape.com
b5f8f8b280 Added call marshaller.
git-svn-id: svn://10.0.0.236/branches/SOAP_20010403_BRANCH@98575 18797224-902f-48f8-a5cc-f745e15eee43
2001-07-03 21:51:47 +00:00
rayw%netscape.com
2f8fb4e18e Somehow file got lost.
git-svn-id: svn://10.0.0.236/branches/SOAP_20010403_BRANCH@98564 18797224-902f-48f8-a5cc-f745e15eee43
2001-07-03 17:10:16 +00:00
rayw%netscape.com
28510b8765 Added class and contract ID for soap struct.
git-svn-id: svn://10.0.0.236/branches/SOAP_20010403_BRANCH@98558 18797224-902f-48f8-a5cc-f745e15eee43
2001-07-03 12:49:25 +00:00
rayw%netscape.com
d1874fd390 Added schemaType for more control of serialization.
git-svn-id: svn://10.0.0.236/branches/SOAP_20010403_BRANCH@98557 18797224-902f-48f8-a5cc-f745e15eee43
2001-07-03 12:38:00 +00:00
rayw%netscape.com
fbb15c34df Added JS property getter/setter.
git-svn-id: svn://10.0.0.236/branches/SOAP_20010403_BRANCH@98519 18797224-902f-48f8-a5cc-f745e15eee43
2001-07-03 01:57:39 +00:00
rayw%netscape.com
c972ffe9ba Added generic object to represent SOAP struct.
git-svn-id: svn://10.0.0.236/branches/SOAP_20010403_BRANCH@98502 18797224-902f-48f8-a5cc-f745e15eee43
2001-07-03 00:35:06 +00:00
rayw%netscape.com
d664af31f8 Changed Enumerator to SimpleEnumerator
git-svn-id: svn://10.0.0.236/branches/SOAP_20010403_BRANCH@98471 18797224-902f-48f8-a5cc-f745e15eee43
2001-07-02 21:14:15 +00:00
rayw%netscape.com
f52285f36f Changed nsLiteralString to nsDependentString
git-svn-id: svn://10.0.0.236/branches/SOAP_20010403_BRANCH@98465 18797224-902f-48f8-a5cc-f745e15eee43
2001-07-02 20:24:48 +00:00
rayw%netscape.com
f04bae5686 Modified adapter marshal/unmarshal to properly derive this pointer.
git-svn-id: svn://10.0.0.236/branches/SOAP_20010403_BRANCH@95604 18797224-902f-48f8-a5cc-f745e15eee43
2001-05-21 18:34:57 +00:00
rayw%netscape.com
b194997c23 Added JS compatibility for marshalling and unmarshalling of Message.
git-svn-id: svn://10.0.0.236/branches/SOAP_20010403_BRANCH@95261 18797224-902f-48f8-a5cc-f745e15eee43
2001-05-17 16:39:52 +00:00
rayw%netscape.com
4b48f91a20 eliminated js stuff from utils.
git-svn-id: svn://10.0.0.236/branches/SOAP_20010403_BRANCH@95251 18797224-902f-48f8-a5cc-f745e15eee43
2001-05-17 11:45:14 +00:00
rayw%netscape.com
7c8eb29757 Fixes to make it compile on landed DOM branch.
git-svn-id: svn://10.0.0.236/branches/SOAP_20010403_BRANCH@95250 18797224-902f-48f8-a5cc-f745e15eee43
2001-05-17 11:13:19 +00:00
rayw%netscape.com
6a4c8c43e4 Fixes, addition of struct.
git-svn-id: svn://10.0.0.236/branches/SOAP_20010403_BRANCH@95249 18797224-902f-48f8-a5cc-f745e15eee43
2001-05-17 11:12:46 +00:00
rayw%netscape.com
02b3b1eea4 Comment out uncompilable stuff.
git-svn-id: svn://10.0.0.236/branches/SOAP_20010403_BRANCH@91908 18797224-902f-48f8-a5cc-f745e15eee43
2001-04-10 22:55:23 +00:00
rayw%netscape.com
ec9c7644b1 Put back to cut to xpconnect branch.
git-svn-id: svn://10.0.0.236/branches/SOAP_20010403_BRANCH@91896 18797224-902f-48f8-a5cc-f745e15eee43
2001-04-10 18:49:24 +00:00
rayw%netscape.com
e935d2168c Noscripted methods to be overloaded for JS.
git-svn-id: svn://10.0.0.236/branches/SOAP_20010403_BRANCH@91895 18797224-902f-48f8-a5cc-f745e15eee43
2001-04-10 18:48:27 +00:00
rayw%netscape.com
c5af273d98 Added methods.
git-svn-id: svn://10.0.0.236/branches/SOAP_20010403_BRANCH@91787 18797224-902f-48f8-a5cc-f745e15eee43
2001-04-09 23:03:15 +00:00
rayw%netscape.com
30313dad10 Added default encoder, el;iminated JS response listener.
git-svn-id: svn://10.0.0.236/branches/SOAP_20010403_BRANCH@91786 18797224-902f-48f8-a5cc-f745e15eee43
2001-04-09 22:56:24 +00:00
rayw%netscape.com
af73391209 Eliminated class IDs that probably will not be needed.
git-svn-id: svn://10.0.0.236/branches/SOAP_20010403_BRANCH@91785 18797224-902f-48f8-a5cc-f745e15eee43
2001-04-09 22:55:42 +00:00
rayw%netscape.com
ccdf7fa709 Added type registry logic.
git-svn-id: svn://10.0.0.236/branches/SOAP_20010403_BRANCH@91777 18797224-902f-48f8-a5cc-f745e15eee43
2001-04-09 21:32:10 +00:00
rayw%netscape.com
89b17c4b68 Latest fixes.
git-svn-id: svn://10.0.0.236/branches/SOAP_20010403_BRANCH@91768 18797224-902f-48f8-a5cc-f745e15eee43
2001-04-09 20:27:20 +00:00
rayw%netscape.com
f8a8ff476b Eliminated encoder includes.
git-svn-id: svn://10.0.0.236/branches/SOAP_20010403_BRANCH@91698 18797224-902f-48f8-a5cc-f745e15eee43
2001-04-08 18:40:10 +00:00
rayw%netscape.com
0f49a6c14d Fixed methods pertaining to converting to / from JavaScript values.
git-svn-id: svn://10.0.0.236/branches/SOAP_20010403_BRANCH@91697 18797224-902f-48f8-a5cc-f745e15eee43
2001-04-08 18:36:21 +00:00
rayw%netscape.com
d915eac613 Eliminated default types from message.
git-svn-id: svn://10.0.0.236/branches/SOAP_20010403_BRANCH@91655 18797224-902f-48f8-a5cc-f745e15eee43
2001-04-07 12:51:06 +00:00
rayw%netscape.com
cea595d018 Changes to marshalling / unmarshalling
git-svn-id: svn://10.0.0.236/branches/SOAP_20010403_BRANCH@91654 18797224-902f-48f8-a5cc-f745e15eee43
2001-04-07 12:48:20 +00:00
rayw%netscape.com
ef58546285 Major changes to marshalling / unmarshalling.
git-svn-id: svn://10.0.0.236/branches/SOAP_20010403_BRANCH@91653 18797224-902f-48f8-a5cc-f745e15eee43
2001-04-07 12:47:56 +00:00
rayw%netscape.com
accd0fc6f2 Fixed inheritance and other issues
git-svn-id: svn://10.0.0.236/branches/SOAP_20010403_BRANCH@91604 18797224-902f-48f8-a5cc-f745e15eee43
2001-04-06 23:48:17 +00:00
rayw%netscape.com
83cb05e038 Eliminated generated fault idl.
git-svn-id: svn://10.0.0.236/branches/SOAP_20010403_BRANCH@91592 18797224-902f-48f8-a5cc-f745e15eee43
2001-04-06 21:33:37 +00:00
rayw%netscape.com
56d1f4013d Eliminated generatedFault boolean.
git-svn-id: svn://10.0.0.236/branches/SOAP_20010403_BRANCH@91591 18797224-902f-48f8-a5cc-f745e15eee43
2001-04-06 21:33:03 +00:00
rayw%netscape.com
4ebd0afc6a Added nsSOAPJSValue basic class to start supporting that.
git-svn-id: svn://10.0.0.236/branches/SOAP_20010403_BRANCH@91582 18797224-902f-48f8-a5cc-f745e15eee43
2001-04-06 17:40:05 +00:00
rayw%netscape.com
f494eac05c Fixed bad manual string conversion.
git-svn-id: svn://10.0.0.236/branches/SOAP_20010403_BRANCH@91578 18797224-902f-48f8-a5cc-f745e15eee43
2001-04-06 15:01:15 +00:00
rayw%netscape.com
b71e0fb70d Took a first cut at nsSOAPParameters, which needed new strings.
git-svn-id: svn://10.0.0.236/branches/SOAP_20010403_BRANCH@91576 18797224-902f-48f8-a5cc-f745e15eee43
2001-04-06 14:37:40 +00:00
rayw%netscape.com
5d4865dae4 Fixed nsSOAPUtils and nsSOAPFault to use DOMStrings and not use
GetElementsByTagName, and better adapted existing work to nsSOAPUtils


git-svn-id: svn://10.0.0.236/branches/SOAP_20010403_BRANCH@91573 18797224-902f-48f8-a5cc-f745e15eee43
2001-04-06 12:19:29 +00:00
rayw%netscape.com
e5524451bc Oops, checked in uncompiled files. Minor misspellings.
git-svn-id: svn://10.0.0.236/branches/SOAP_20010403_BRANCH@91531 18797224-902f-48f8-a5cc-f745e15eee43
2001-04-06 00:48:11 +00:00
rayw%netscape.com
ff9050d3f4 Fixed memory leaks and incorrect protected static declaration.
git-svn-id: svn://10.0.0.236/branches/SOAP_20010403_BRANCH@91530 18797224-902f-48f8-a5cc-f745e15eee43
2001-04-06 00:45:07 +00:00
rayw%netscape.com
4be8d0eeec First check in that might actually be complete (for now).
git-svn-id: svn://10.0.0.236/branches/SOAP_20010403_BRANCH@91497 18797224-902f-48f8-a5cc-f745e15eee43
2001-04-05 22:37:37 +00:00
rayw%netscape.com
d080ca9d5f I fixed a bunch of minor things and major on marshall/unmarshall calls.
git-svn-id: svn://10.0.0.236/branches/SOAP_20010403_BRANCH@91496 18797224-902f-48f8-a5cc-f745e15eee43
2001-04-05 22:36:53 +00:00
rayw%netscape.com
26f06043ba Moved actionURI to message.
git-svn-id: svn://10.0.0.236/branches/SOAP_20010403_BRANCH@91458 18797224-902f-48f8-a5cc-f745e15eee43
2001-04-05 13:40:32 +00:00
rayw%netscape.com
ea12749483 Movec action back to message, since it makes it much easier for marshallers
and unmarshallers.


git-svn-id: svn://10.0.0.236/branches/SOAP_20010403_BRANCH@91457 18797224-902f-48f8-a5cc-f745e15eee43
2001-04-05 13:35:52 +00:00
rayw%netscape.com
0ea210ce81 First stab at a shell response class.
git-svn-id: svn://10.0.0.236/branches/SOAP_20010403_BRANCH@91456 18797224-902f-48f8-a5cc-f745e15eee43
2001-04-05 13:29:29 +00:00
rayw%netscape.com
6741f7a847 Added new version of nsSOAPMessage implementation, as only working file
in the directory thus far.


git-svn-id: svn://10.0.0.236/branches/SOAP_20010403_BRANCH@91453 18797224-902f-48f8-a5cc-f745e15eee43
2001-04-05 12:44:08 +00:00
rayw%netscape.com
14f3c13cc2 Removed in new version of SOAP APIs.
git-svn-id: svn://10.0.0.236/branches/SOAP_20010403_BRANCH@91308 18797224-902f-48f8-a5cc-f745e15eee43
2001-04-04 15:01:12 +00:00
rayw%netscape.com
d485fb8f40 New file added for new APIs.
git-svn-id: svn://10.0.0.236/branches/SOAP_20010403_BRANCH@91307 18797224-902f-48f8-a5cc-f745e15eee43
2001-04-04 14:59:18 +00:00
rayw%netscape.com
fb1ca8255a SOAP branch for new version of APIs.
git-svn-id: svn://10.0.0.236/branches/SOAP_20010403_BRANCH@91306 18797224-902f-48f8-a5cc-f745e15eee43
2001-04-04 14:58:24 +00:00
(no author)
b356164ebc This commit was manufactured by cvs2svn to create branch
'SOAP_20010403_BRANCH'.

git-svn-id: svn://10.0.0.236/branches/SOAP_20010403_BRANCH@88949 18797224-902f-48f8-a5cc-f745e15eee43
2001-03-08 08:05:07 +00:00
359 changed files with 12572 additions and 106012 deletions

View File

@@ -0,0 +1,50 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Netscape 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/NPL/
*
* Software distributed under the License is distributed on an "AS
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
* implied. See the License for the specific language governing
* rights and limitations under the License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 2001 Netscape Communications Corporation. All
* Rights Reserved.
*
* Contributor(s):
*/
#include "nsISupports.idl"
/**
* This interface permits attachment of SOAP attachments.
*/
[scriptable, uuid(6192dcbe-1dd2-11b2-81ad-a4597614c4ae)]
interface nsISOAPAttachments : nsISupports {
/**
* Get the attachment associated with a particular identifier.
*
* @param aIdentifier The identifier of the attachment to be accessed.
*
* Appropriate return(s) must be identified.
*/
void getAttachment(in AString aIdentifier);
/**
* Attach an attachment to the message.
*
* Appropriate argument(s) must be identified.
*
* @return The identifier of the attachment, to be referenced in SOAP encoding
*/
AString attach();
};

View File

@@ -0,0 +1,90 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Netscape 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/NPL/
*
* Software distributed under the License is distributed on an "AS
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
* implied. See the License for the specific language governing
* rights and limitations under the License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 2001 Netscape Communications Corporation. All
* Rights Reserved.
*
* Contributor(s):
*/
#include "nsISupports.idl"
#include "nsISOAPMessage.idl"
interface nsISOAPResponse;
interface nsISOAPResponseListener;
/**
* This interface is a convenience extension of the basic SOAP message,
* which handles common patterns of calling, such as providing an
* action URI in the HTTP header, locating and invoking the appropriate
* transport based upon the protocol of the transportURI, and
* automatically recieving the result in a new nsISOAPResponse object
* which recieves an XML message.
*/
[scriptable, uuid(a8fefe40-52bc-11d4-9a57-000064657374)]
interface nsISOAPCall : nsISOAPMessage {
/**
* The URI to which the message will be sent, identifying the
* transport and transport-specific information about the
* destination.
* This does not have to match the <code>targetObjectURI</code>.
*/
attribute AString transportURI;
/**
* Synchronously invoke the call. The method returns only when
* we receive a response (or an error occurs). The
* <code>transportURI</code> must have been set, the
* parameter list (even if empty) must have been encoded,
* and the transportURI must use some known protocol. A
* synchronous call assumes that there will be exactly one
* response per call.
*
* If not, an error is returned in the status of the response.
*
* @returns The SOAP response
*/
nsISOAPResponse invoke();
/**
* Asynchronously invoke the call. At this point, the document
* rooted by the Envelope element is encoded to form the body
* of the SOAP message. The method returns immediately, and the
* listener is invoked when we eventually receive a response
* (or error or successful completion). The
* <code>transportURI</code> must have been set, the
* parameter list (even if empty) must have been encoded,
* and the transportURI must use some known protocol.
*
* If not, an error is returned in the status of the response.
*
* @param aListener Handler to be invoked asynchronously after the
* response is recieved. Should be null if no response is
* expected.
*/
void asyncInvoke(in nsISOAPResponseListener aListener);
};
%{ C++
#define NS_SOAPCALL_CID \
{ /* 87d21ec0-539d-11d4-9a59-00104bdf5339 */ \
0x87d21ec0, 0x539d, 0x11d4, \
{0x9a, 0x59, 0x00, 0x10, 0x4b, 0xdf, 0x53, 0x39} }
#define NS_SOAPCALL_CONTRACTID \
"@mozilla.org/xmlextras/soap/call;1"
%}

View File

@@ -0,0 +1,61 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Netscape 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/NPL/
*
* Software distributed under the License is distributed on an "AS
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
* implied. See the License for the specific language governing
* rights and limitations under the License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 2001 Netscape Communications Corporation. All
* Rights Reserved.
*
* Contributor(s):
*/
#include "nsISupports.idl"
interface nsISchemaType;
interface nsISOAPEncoding;
interface nsIDOMElement;
interface nsIVariant;
interface nsISOAPAttachments;
/**
* This interface supplies decoding of a specific
* part of a message XML DOM into appropriate objects
* for the script or application.
*/
[scriptable, uuid(4c2e02ae-1dd2-11b2-b1cd-c79dea3d46db)]
interface nsISOAPDecoder : nsISupports {
/**
* Decode the source DOM node
*
* @param aEncodings The encodings used to decode
*
* @param aEncodingStyleURI The encoding style
*
* @param aSource The DOM node to be decoded.
*
* @param aSchemaType The schema type of the source DOM node
*
* @param aAttachments Dispenses any attachments.
*
* @return The decoded variant, which is null if
* the operation failed or did not return a result.
*/
nsIVariant decode(
in nsISOAPEncoding aEncoding,
in nsIDOMElement aSource,
in nsISchemaType aSchemaType,
in nsISOAPAttachments aAttachments);
};

View File

@@ -0,0 +1,69 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Netscape 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/NPL/
*
* Software distributed under the License is distributed on an "AS
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
* implied. See the License for the specific language governing
* rights and limitations under the License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 2001 Netscape Communications Corporation. All
* Rights Reserved.
*
* Contributor(s):
*/
#include "nsISupports.idl"
interface nsISchemaType;
interface nsISOAPEncoding;
interface nsIVariant;
interface nsIDOMElement;
interface nsISOAPAttachments;
/**
* This interface permits encoding of variants.
*/
[scriptable, uuid(fc33ffd6-1dd1-11b2-8750-fa62430a38b4)]
interface nsISOAPEncoder : nsISupports {
/**
* Encode the source variant.
*
* @param aEncodings The encodings to be used.
*
* @param aEncodingStyleURI The encoding style
*
* @param aSource The variant to be encoded.
*
* @param aNamespaceURI The namespace of the thing being coded
*
* @param aName The name of the thing being coded
*
* @param aSchemaType The schema type of the thing being encoded
*
* @param aDestination The node scope, if any, where the result
* will live. If this is null, then the result must be
* explicitly attached to the message.
*
* @return element which was inserted.
*
* @param aAttachments Accumulates any attachments.
*/
nsIDOMElement encode(
in nsISOAPEncoding aEncoding,
in nsIVariant aSource,
in AString aNamespaceURI,
in AString aName,
in nsISchemaType aSchemaType,
in nsISOAPAttachments aAttachments,
in nsIDOMElement aDestination);
};

View File

@@ -0,0 +1,184 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Netscape 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/NPL/
*
* Software distributed under the License is distributed on an "AS
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
* implied. See the License for the specific language governing
* rights and limitations under the License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 2001 Netscape Communications Corporation. All
* Rights Reserved.
*
* Contributor(s):
*/
#include "nsISupports.idl"
interface nsISchemaType;
interface nsIDOMElement;
interface nsISOAPEncoder;
interface nsISOAPDecoder;
interface nsISOAPMessage;
interface nsIVariant;
interface nsISOAPAttachments;
interface nsISchemaCollection;
/**
* This interface keeps track of all the known types and how
* each should be encoded (by type) or decoded (by
* schema type)
*/
[scriptable, uuid(9ae49600-1dd1-11b2-877f-e62f620c5e92)]
interface nsISOAPEncoding : nsISupports {
/**
* The name of the encoding as it is known to SOAP.
*/
readonly attribute AString styleURI;
/**
* Get an alternative encoding.
*
* @param aStyleURI The style URI of the alternative encoding style.
*
* @param aCreateIf If true, then create the alternative style if it
* does not already exist, otherwise return the existing encoding.
*
* @return The alternative encoding which corresponds to the
* specified styleURI, or null if the spefied alternative encoding
* does not exist and it was not requested that it be created.
*/
nsISOAPEncoding getStyle(
in AString aStyleURI,
in boolean aCreateIf);
/**
* Set an encoder in the encoding.
*
* @param aSchemaNamespaceURI The schema namespace URI to serve as key.
*
* @param aSchemaType The schema type to serve as key.
*
* @param aEncoder The encoder to be specified or null to eliminate
* the encoder.
*
* @return Old encoder registered under that type in the encoding, which
* should be kept by the new encoder if it is to be called back.
*/
void setEncoder(in AString aSchemaNamespaceURI, in AString aSchemaType,
in nsISOAPEncoder aEncoder);
/**
* Get an encoder from the encoding.
*
* @param aSchemaNamespaceURI The schema namespace URI to serve as key.
*
* @param aSchemaType The schema type to serve as key.
*
* @return The encoder.
*/
nsISOAPEncoder getEncoder(in AString aSchemaNamespaceURI, in AString aSchemaType);
/**
* Set a decoder in the encoding.
*
* @param aSchemaNamespaceURI The schema namespace URI to serve as key.
*
* @param aSchemaType The schema type to serve as key.
*
* @param aDecoder The decoder to be specified or null to eliminate
* the decoder.
*
* @return Old decoder registered under that type in the encoding, which
* should be kept by the new decoder if it is to be called back.
*/
void setDecoder(in AString aSchemaNamespaceURI, in AString aSchemaType,
in nsISOAPDecoder aDecoder);
/**
* Get a decoder from the encoding.
*
* @param aSchemaNamespaceURI The schema namespace URI to serve as key.
*
* @param aSchemaType The schema type to serve as key.
*
* @return The decoder.
*/
nsISOAPDecoder getDecoder(in AString aSchemaNamespaceURI, in AString aSchemaType);
attribute nsISOAPEncoder defaultEncoder;
attribute nsISOAPDecoder defaultDecoder;
attribute nsISchemaCollection schemaCollection;
/**
* Encode the source variant
*
* @param aEncodings The encodings to be used.
*
* @param aEncodingStyleURI The encoding style
*
* @param aSource The variant to be encoded, soon to become a variant
*
* @param aNamespaceURI The namespace of the thing being coded
*
* @param aName The name of the thing being coded
*
* @param aSchemaType The schema type of the thing being encoded
*
* @param aDestination The node scope where the result will live.
*
* @param aAttachments Accumulates any attachments.
*
* @return The element which was inserted and encoded.
*/
nsIDOMElement encode(
in nsIVariant aSource,
in AString aNamespaceURI,
in AString aName,
in nsISchemaType aSchemaType,
in nsISOAPAttachments aAttachments,
in nsIDOMElement aDestination);
/**
* Decode the source DOM node
*
* @param aEncodings The encodings used to decode
*
* @param aEncodingStyleURI The encoding style
*
* @param aSource The DOM node to be decoded.
*
* @param aSchemaType The schema type of the source DOM node
*
* @param aAttachments Dispenses any attachments.
*
* @return The decoded variant, soon to become a variant, which is null if
* the operation failed or did not return a result.
*/
nsIVariant decode(
in nsIDOMElement aSource,
in nsISchemaType aSchemaType,
in nsISOAPAttachments aAttachments);
};
%{ C++
#define NS_DEFAULTSOAPENCODER_CID \
{ /* 06fb035c-1dd2-11b2-bc30-f6d8e314d6b9 */ \
0x06fb035c, 0x1dd2, 0x11b2, \
{0xbc, 0x30, 0xf6, 0xd8, 0xe3, 0x14, 0xd6, 0xb9} }
#define NS_SOAPENCODING_CONTRACTID_PREFIX \
"@mozilla.org/xmlextras/soap/encoding;1?uri="
#define NS_DEFAULTSOAPENCODER_CONTRACTID \
NS_SOAPENCODING_CONTRACTID_PREFIX "http://schemas.xmlsoap.org/soap/encoding/"
%}

View File

@@ -0,0 +1,69 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Netscape 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/NPL/
*
* Software distributed under the License is distributed on an "AS
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
* implied. See the License for the specific language governing
* rights and limitations under the License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 2001 Netscape Communications Corporation. All
* Rights Reserved.
*
* Contributor(s):
*/
#include "nsISupports.idl"
interface nsIDOMElement;
/**
* This interface conveniently interprets information about a fault
* that has been returned in a response message.
*
*/
[scriptable, uuid(99ec6694-535f-11d4-9a58-000064657374)]
interface nsISOAPFault : nsISupports {
/**
* The DOM element representing the fault in the response SOAP message.
* This must be set for the rest of the interface to function correctly.
*/
attribute nsIDOMElement element;
/**
* The fault code
*/
readonly attribute AString faultCode;
/**
* The fault string
*/
readonly attribute AString faultString;
/**
* The fault actor if one was specified.
*/
readonly attribute AString faultActor;
/**
* The DOM element representing the fault details
*/
readonly attribute nsIDOMElement detail;
};
%{ C++
#define NS_SOAPFAULT_CID \
{ /* 87d21ec1-539d-11d4-9a59-00104bdf5339 */ \
0x87d21ec1, 0x539d, 0x11d4, \
{0x9a, 0x59, 0x00, 0x10, 0x4b, 0xdf, 0x53, 0x39} }
#define NS_SOAPFAULT_CONTRACTID \
"@mozilla.org/xmlextras/soap/fault;1"
%}

View File

@@ -0,0 +1,96 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Netscape 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/NPL/
*
* Software distributed under the License is distributed on an "AS
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
* implied. See the License for the specific language governing
* rights and limitations under the License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 2001 Netscape Communications Corporation. All
* Rights Reserved.
*
* Contributor(s):
*/
#include "nsISupports.idl"
interface nsIDOMElement;
interface nsIVariant;
interface nsISOAPEncoding;
interface nsISchemaType;
interface nsISOAPAttachments;
/**
* This interface encapsulates an arbitrary header block to be used
* by the soap serialization or protocol. It formalizes a type
* string, a reference to the object, and a name.
*/
[scriptable, uuid(063d4a4e-1dd2-11b2-a365-cbaf1651f140)]
interface nsISOAPHeaderBlock : nsISupports {
/**
* The namespace URI of the header block. Ignored if name is null.
*/
attribute AString namespaceURI;
/**
* The name of the header block. If the header block is left unnamed, it
* will be encoded using the element types defined in the SOAP-ENC
* schema. For example, <code>&lt;SOAP-ENC:int&gt;45&lt;/SOAP-ENC:int&gt;
* </code>
*/
attribute AString name;
/**
* The actor URI of the header block.
*/
attribute AString actorURI;
/**
* The encoding that was / will be applied to the
* header block.
*/
attribute nsISOAPEncoding encoding;
/**
* The schema type used to encode or decode the
* header block.
*/
attribute nsISchemaType schemaType;
/**
* The element which is the encoded value of this header block.
* If this is set, value becomes a computed attribute
* which is produced by decoding this element.
*/
attribute nsIDOMElement element;
/**
* The native value which is the decoded value of
* this header block. If this is set, element becomes null.
*/
attribute nsIVariant value;
/**
* The attachments which were attached to the message.
*/
attribute nsISOAPAttachments attachments;
};
%{ C++
#define NS_SOAPHEADERBLOCK_CID \
{ /* 5ad0eace-1dd2-11b2-a260-ff42edcaedb3 */ \
0x5ad0eace, 0x1dd2, 0x11b2, \
{0xa2, 0x60, 0xff, 0x42, 0xed, 0xca, 0xed, 0xb3} }
#define NS_SOAPHEADERBLOCK_CONTRACTID \
"@mozilla.org/xmlextras/soap/headerblock;1"
%}

View File

@@ -0,0 +1,196 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Netscape 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/NPL/
*
* Software distributed under the License is distributed on an "AS
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
* implied. See the License for the specific language governing
* rights and limitations under the License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 2001 Netscape Communications Corporation. All
* Rights Reserved.
*
* Contributor(s):
*/
#include "nsISupports.idl"
interface nsIDOMDocument;
interface nsIDOMElement;
interface nsISOAPEncoding;
interface nsISOAPHeaderBlock;
interface nsISOAPParameter;
interface nsIVariant;
/**
* This interface controls all SOAP messages. It permits easy
* construction of a message, typically through encoding of
* parameters and certain properties settable on this interface
* or through deserialization of a transport stream. It
* permits easy processing of a message typically through
* decoding of parameters and certain properties available
* on this interface. It also encapsulates protocol information
* interpreted by the transport.
*/
[scriptable, uuid(3970815e-1dd2-11b2-a475-db4dac6826f1)]
interface nsISOAPMessage : nsISupports {
/**
* The document which captures the message, if any. A simple
* sending application passes parameters to the method
* encodeSOAPParameters, which calls SOAP encoders
* to construct this document along with all contained elements.
*
* But an application may create and set the message directly
* instead of invoking encodeSOAPParameters to use encoders
* or access and manipulate the message after it has been
* constructed by encodeSOAPParameters. If the message has
* not been set, invoking a call will fail. A message reciever
* may also use this accessor to get the document to avoid using
* decoders.
*/
attribute nsIDOMDocument message;
/**
* A convenience attribute to obtain the DOM element representing the
* SOAP envelope from the document. DOM methods may be used to
* access, add, or modify attributes of the envelope.
*
* If the message attribute is null or is not a document containing
* a root soap envelope element, then this will be null.
*/
readonly attribute nsIDOMElement envelope;
/**
* A convenience attribute to obtain the DOM element representing the
* SOAP header from the envelope. DOM methods may be used to
* access, add, or modify attributes or elements of the header.
*
* If the envelope attribute is null or does not contain a SOAP header
* element type, then this will be null.
*/
readonly attribute nsIDOMElement header;
/**
* A convenience attribute to obtain the DOM element representing the
* SOAP body from the envelope. DOM methods may be used to
* access, add, or modify attributes or elements of the body.
*
* If the envelope attribute is null or does not contain a SOAP body
* element type, then this will be null.
*/
readonly attribute nsIDOMElement body;
/**
* The name of the method being invoked. The methodName is set
* during encoding as the tagname of the single child of body
* of RPC-style messages. When there is no encoded message
* this will be null. The value of this attribute for
* document-style messages may be non-null but should be
* ignored. It is up to the application to know whether the
* message is RPC-style or document style because the SOAP
* specification makes it difficult to tell which way a
* message was encoded.
*/
readonly attribute AString methodName;
/**
* The target object on which the method is being invoked. This URI
* is set during encoding as the namespace to qualify the tagname
* of the single child of body of RPC-style messages. When there
* is no encoded message, this will be null. The value of this
* attribute for document-style messages may be non-null but should
* be ignored. It is up to the application to know whether the
* message is RPC-style or document style because the SOAP
* specification makes it difficult to tell which way a
* message was encoded.
*/
readonly attribute AString targetObjectURI;
/**
* Encodes the specified parameters into this message, if
* this message type supports it.
*
* @param aMethodName The name of the method being invoked
* for rpc-style messages. For document-style messages,
* this must be null.
*
* @param aTargetObjectURI The name of the target object
* for rpc-style messages. For document-style messages,
* this must be null.
*
* @param aHeaderBlockCount Number of header blocks in array to be
* encoded. Must be 0 if header block array is null.
*
* @param aHeaderBlocks Array of header blocks to be encoded, which
* may be null if there are no header blocks.
*
* @param aParameterCount Number of parameters in array
* to be encoded. Must be 0 if parameter array is null.
*
* @param aParameters An array of parameters to be
* encoded, which may null if there are no parameters.
*/
void encode(
in AString aMethodName, in AString aTargetObjectURI,
in PRUint32 aHeaderBlockCount,
[array, size_is(aHeaderBlockCount)] in nsISOAPHeaderBlock aHeaderBlocks,
in PRUint32 aParameterCount,
[array, size_is(aParameterCount)] in nsISOAPParameter aParameters);
/**
* Gathers the header blocks of a message so that they can be
* accessed by a recipient.
*
* @param aCount Integer to receive the length of the list
* of header blocks.
*
* @return Array of header blocks found in the message.
*/
void getHeaderBlocks(out PRUint32 aCount,
[array, size_is(aCount), retval] out nsISOAPHeaderBlock aHeaderBlocks);
/**
* Gathers the parameters of a message so that they can be
* accessed by a recipient.
*
* @param aDocumentStyle If true, then the parameters
* are looked for treating the message as a document
* style message, otherwise it treated as an RPC-style
* message.
*
* @param aCount Integer to receive the length of the list
* of parameters.
*
* @return Array of parameters found in the message.
*/
void getParameters(in boolean aDocumentStyle,
out PRUint32 aCount,
[array, size_is(aCount), retval] out nsISOAPParameter aParameters);
/**
* The primary encoding of the message, which is established
* at the envelope and used unless overridden. By default,
* this is the SOAP encoding, which may be locally modified
* or used to obtain alternative encodings, which may be
* locally modified, but it may be set to an encoding that
* is shared, or it may be set to null, in which case all
* non-literal header blocks and parameters must specify an
* encoding.
*/
attribute nsISOAPEncoding encoding;
/**
* An optional URI that can be used to add a SOAPAction HTTP
* header field. If this attribute is NULL (the default case),
* no SOAPAction header will be added.
*/
attribute AString actionURI;
};

View File

@@ -0,0 +1,93 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Netscape 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/NPL/
*
* Software distributed under the License is distributed on an "AS
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
* implied. See the License for the specific language governing
* rights and limitations under the License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 2001 Netscape Communications Corporation. All
* Rights Reserved.
*
* Contributor(s):
*/
#include "nsISupports.idl"
interface nsIDOMElement;
interface nsIVariant;
interface nsISOAPEncoding;
interface nsISchemaType;
interface nsISOAPAttachments;
/**
* This interface encapsulates an arbitrary parameter to be used
* by the soap serialization or protocol. It formalizes a type
* string, a reference to the object, and a name.
*/
[scriptable, uuid(99ec6690-535f-11d4-9a58-000064657374)]
interface nsISOAPParameter : nsISupports {
/**
* The namespace URI of the parameter. Ignored if name is null.
*/
attribute AString namespaceURI;
/**
* The name of the parameter. If the parameter is left unnamed, it
* will be encoded using the element types defined in the SOAP-ENC
* schema. For example, <code>&lt;SOAP-ENC:int&gt;45&lt;/SOAP-ENC:int&gt;
* </code>
*/
attribute AString name;
/**
* The encoding that was / will be applied to the
* parameter.
*/
attribute nsISOAPEncoding encoding;
/**
* The schema type used to encode or decode the
* parameter.
*/
attribute nsISchemaType schemaType;
/**
* The element which is the encoded value of this parameter.
* If this is set, value becomes a computed attribute
* which may be produced by decoding this element.
*/
attribute nsIDOMElement element;
/**
* The native value which is the decoded value of
* this parameter. If this is set, element becomes
* null.
*/
attribute nsIVariant value;
/**
* The attachments which were attached to the message
* that may be needed to decode the parameter.
*/
attribute nsISOAPAttachments attachments;
};
%{ C++
#define NS_SOAPPARAMETER_CID \
{ /* 87d21ec2-539d-11d4-9a59-00104bdf5339 */ \
0x87d21ec2, 0x539d, 0x11d4, \
{0x9a, 0x59, 0x00, 0x10, 0x4b, 0xdf, 0x53, 0x39} }
#define NS_SOAPPARAMETER_CONTRACTID \
"@mozilla.org/xmlextras/soap/parameter;1"
%}

View File

@@ -0,0 +1,63 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Netscape 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/NPL/
*
* Software distributed under the License is distributed on an "AS
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
* implied. See the License for the specific language governing
* rights and limitations under the License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 2001 Netscape Communications Corporation. All
* Rights Reserved.
*
* Contributor(s):
*/
#include "nsISupports.idl"
#include "nsISOAPCall.idl"
interface nsISOAPParameter;
interface nsISOAPFault;
/**
* This is an extension of a message which contains extra functions
* such as tracking, where appropriate, the original call that
* produced the response message, identifying the fault, if any,
* and supplying the return value.
*/
[scriptable, uuid(99ec6691-535f-11d4-9a58-000064657374)]
interface nsISOAPResponse : nsISOAPMessage {
/**
* The message which generated this response. There is no guarantee
* that the message has not been modified since the original call
* occurred. This is set automatically when invoking a call that
* returns this response. This must also be set by a call processor
* so that the transport can return a response to the correct caller.
*/
attribute nsISOAPCall respondingTo;
/**
* The fault returned in the response, if one was generated. NULL
* if there was no fault. This does not rely on the response
* parameters having been deserialized.
*/
readonly attribute nsISOAPFault fault;
};
%{ C++
#define NS_SOAPRESPONSE_CID \
{ /* 87d21ec3-539d-11d4-9a59-00104bdf5339 */ \
0x87d21ec3, 0x539d, 0x11d4, \
{0x9a, 0x59, 0x00, 0x10, 0x4b, 0xdf, 0x53, 0x39} }
#define NS_SOAPRESPONSE_CONTRACTID \
"@mozilla.org/xmlextras/soap/response;1"
%}

View File

@@ -0,0 +1,61 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Netscape 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/NPL/
*
* Software distributed under the License is distributed on an "AS
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
* implied. See the License for the specific language governing
* rights and limitations under the License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 2001 Netscape Communications Corporation. All
* Rights Reserved.
*
* Contributor(s):
*/
#include "nsISupports.idl"
interface nsISOAPCall;
interface nsISOAPResponse;
/**
* This interface represents a response handler to be invoked whenever
* a response of a particular call is recieved and when no more
* responses are expected.
*/
[scriptable, uuid(99ec6692-535f-11d4-9a58-000064657374)]
interface nsISOAPResponseListener : nsISupports {
/**
* This method is invoked when we receive an asynchronous response to
* a SOAP message. The listener is registered as part of the original
* asynchronous call invocation.
*
* @param aResponse The decoded version of the response. If an
* error occurred transmitting the response, the status field
* of the response will contain an error code. The last call
* to the listener may contain a null response, which should
* only be interpreted as an error if your call expected more
* results than it got. If the service or the transport
* do not know whether to expect more results, then setting
* the last parameter true may only be possible after the
* last response has already been delivered.
*
* @param aLast True if this is the last call to the listener.
*
* @return True to make this the last call to the listener, even
* if last was not true. Calls which expect a single response
* should return true upon receiving that response to avoid
* possibly recieving another callback with a null response
* indicating that the last response was already sent.
*/
boolean handleResponse(in nsISOAPResponse aResponse,
in nsISOAPCall aCall, in unsigned long status, in boolean aLast);
};

View File

@@ -0,0 +1,65 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Netscape 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/NPL/
*
* Software distributed under the License is distributed on an "AS
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
* implied. See the License for the specific language governing
* rights and limitations under the License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 2001 Netscape Communications Corporation. All
* Rights Reserved.
*
* Contributor(s):
*/
#include "nsISupports.idl"
interface nsISOAPMessage;
interface nsISOAPResponseListener;
/**
* This interface describes a service which may be
* applied to incoming messages. The service is
* responsible for determining whether the message
* is one that it should process and rejecting it
* if it is not. Services may be chained.
*/
[scriptable, uuid(9927fa40-1dd1-11b2-a8d1-857ad21b872c)]
interface nsISOAPService : nsISupports {
/**
* Configuration object that may contain more info on the service
*/
attribute nsISupports configuration;
/**
* Process an incoming message.
*
* @param aMessage message to be processed
*
* @param aListener listener to which to report results
*
* @return True if the message will be handled, false if
* it should be given to some other service or fail.
* In case of failure, a more detailed status will be
* recorded in the message.
*/
boolean process(in nsISOAPMessage aMessage,
in nsISOAPResponseListener aListener);
};
%{ C++
#define NS_SOAPJSSERVICE_CID \
{ /* 26a41df2-1dd2-11b2-9f29-909e637afa0e */ \
0x26a41df2, 0x1dd2, 0x11b2, \
{0x9f, 0x29, 0x90, 0x9e, 0x63, 0x7a, 0xfa, 0x0e} }
#define NS_SOAPJSSERVICE_CONTRACTID \
"@mozilla.org/xmlextras/soap/jsservice;1"
%}

View File

@@ -0,0 +1,93 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Netscape 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/NPL/
*
* Software distributed under the License is distributed on an "AS
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
* implied. See the License for the specific language governing
* rights and limitations under the License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 2001 Netscape Communications Corporation. All
* Rights Reserved.
*
* Contributor(s):
*/
#include "nsISupports.idl"
interface nsIDOMElement;
interface nsISOAPService;
interface nsISOAPEncodingRegistry;
/**
* This interface represents a registry of SOAP services.
* This registry recieves transports to listen for messages
* and services to hand the messages to. Service registries
* may be created as required. Destroying a service registry
* stops the registry's action. To temporarily register
* services, create a new registry. For proper order of
* listening precedence, registries should be destroyed
* in reverse order. Otherwise, a listening priority
* would be required.
*/
[scriptable, uuid(9790d6bc-1dd1-11b2-afe0-bcb310c078bf)]
interface nsISOAPServiceRegistry {
/**
* Process a configuration and add the resulting sources
* and services. This will fail if errors occur during
* processing of the configuration.
*
* @param aConfiguration Root element of configuration XML.
*/
boolean addConfiguration(in nsIDOMElement aConfiguration);
/**
* Add a transport to be serviced by the registered services.
* This will fail if the specified source was already added
* with the same setting of the capture flag.
*
* @param aTransport string specifying the transport to supply
* messages for the service.
*
* @param aCapture True if capturing before later declarations
*/
void addSource(in AString aTransport, in boolean aCapture);
/**
* Add a service to service the registered transports. This
* will fail if the specified service was already added.
*
* @param aService Service to be serviced.
*/
void addService(in nsISOAPService aService);
/**
* Registry identifying how to encode and decode
* messages containing specific types, automatically
* added to messages sent to services in this
* registry.
*/
attribute nsISOAPEncodingRegistry encodings;
};
%{ C++
#define NS_SOAPSERVICEREGISTRY_CID \
{ /* 3869184e-1dd2-11b2-aa36-d8333498043a */ \
0x3869184e, 0x1dd2, 0x11b2, \
{0xaa, 0x36, 0xd8, 0x33, 0x34, 0x98, 0x04, 0x3a} }
#define NS_SOAPSERVICEREGISTRY_CONTRACTID \
"@mozilla.org/xmlextras/soap/serviceregistry;1"
#define NS_SOAPDEFAULTSERVICEREGISTRY_CID \
{ /* 9120a01e-1dd2-11b2-a61f-906766927a4f */ \
0x9120a01e, 0x1dd2, 0x11b2, \
{0xa6, 0x1f, 0x90, 0x67, 0x66, 0x92, 0x7a, 0x4f} }
#define NS_SOAPDEFAULTSERVICEREGISTRY_CONTRACTID \
"@mozilla.org/xmlextras/soap/defaultserviceregistry;1"
%}

View File

@@ -0,0 +1,102 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Netscape 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/NPL/
*
* Software distributed under the License is distributed on an "AS
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
* implied. See the License for the specific language governing
* rights and limitations under the License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 2001 Netscape Communications Corporation. All
* Rights Reserved.
*
* Contributor(s):
*/
#include "nsISupports.idl"
interface nsISOAPTransportListener;
interface nsISOAPCall;
interface nsISOAPResponse;
interface nsISOAPResponseListener;
[scriptable, uuid(99ec6695-535f-11d4-9a58-000064657374)]
interface nsISOAPTransport : nsISupports {
/**
* Send the specified message to the specified destination.
* This will fail if synchronous calls are not supported or if there is any
* failure in the actual message exchange. Failure of the call itself will be
* contained in the response.
*
* @param aCall Actual message to be sent.
*
* @param aResponse Message to be recieved. Calling synchronously assumes that
* exactly one response is expected.
*/
void syncCall( in nsISOAPCall aCall,
in nsISOAPResponse aResponse);
/**
* Send the specified message to the specified destination synchronously waiting
* for completion and any response.
* This will fail if there is any failure in the setup of the message exchange.
* Later errors will only be known through the response listener. Failures of the
* call itself will be contained in the response passed to the response listener.
*
* @param aCall Actual message to be sent.
*
* @param aListener Handler to be invoked (single threaded) as each response is
* received and finally with null. If specified as null, no responses are returned.
*
* @param response Message to recieve response and be handled by listener. May be
* null if listener is null.
*/
void asyncCall(in nsISOAPCall aCall,
in nsISOAPResponseListener aListener,
in nsISOAPResponse aResponse);
/**
* Add listener for unsolicited messages arriving on the transport. Listeners
* are provided with the opportunity to accept and process messages. Typically
* a listener will be a service dispatcher. Listeners will be invoked in the
* reverse order of declaration, allowing more local service dispatchers to
* temporarily override permanent service dispatchers. This will fail if the
* desired listener was already added to the transport with the specified
* capture flag or if the transport does not support incoming messages.
*
* @param aListener The listener to recieve unsolicited messages from the
* transport.
*
* @param aCapture True if the listener should capture the message before
* later-declared services.
*/
void addListener(in nsISOAPTransportListener aListener, in boolean aCapture);
/**
* Remove listener for unsolicited messages arriving on the transport. This
* will fail if the specified listener was not added with the specified
* capture setting.
*
* @param aListener The listener to stop from recieving unsolicited messages
* from the transport.
*
* @param aCapture True if the listener was added to capture the message before
* later-declared services (must be specified to remove, since a listener
* may be registered as both).
*/
void removeListener(in nsISOAPTransportListener aListener, in boolean aCapture);
};
%{ C++
#define NS_SOAPTRANSPORT_CONTRACTID \
"@mozilla.org/xmlextras/soap/transport;1"
#define NS_SOAPTRANSPORT_CONTRACTID_PREFIX NS_SOAPTRANSPORT_CONTRACTID "?protocol="
%}

View File

@@ -0,0 +1,50 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Netscape 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/NPL/
*
* Software distributed under the License is distributed on an "AS
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
* implied. See the License for the specific language governing
* rights and limitations under the License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 2001 Netscape Communications Corporation. All
* Rights Reserved.
*
* Contributor(s):
*/
#include "nsISupports.idl"
interface nsIDOMDocument;
interface nsISOAPMessage;
/**
* This interface recieves control when an unsolicited transport
* is recieved on a transport.
*/
[scriptable, uuid(99ec6696-535f-11d4-9a58-000064657374)]
interface nsISOAPTransportListener : nsISupports {
/**
* This method is invoked when an unsolicited message is
* recieved. First all listeners are tried in the order declared
* with the capture flag set. Then all listeners are tried in
* the reverse order declared with the capture flag clear.
*
* @param aMessage Actual message.
*
* @param aCapture True if the listener is being permitted to gain
* control before all later-added listeners.
*
* @return true if message is handled, false if it was not
*/
boolean handleMessage(in nsISOAPMessage aMessage, in boolean aCapture);
};

View File

@@ -0,0 +1,31 @@
#
# The contents of this file are subject to the Mozilla Public
# License Version 1.1 (the "License"); you may not use this file
# except in compliance with the License. You may obtain a copy of
# the License at http://www.mozilla.org/MPL/
#
# Software distributed under the License is distributed on an "AS
# IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
# implied. See the License for the specific language governing
# rights and limitations under the License.
#
# The Original Code is mozilla.org code.
#
# The Initial Developer of the Original Code is Netscape
# Communications Corporation. Portions created by Netscape are
# Copyright (C) 1998 Netscape Communications Corporation. All
# Rights Reserved.
#
# Contributor(s):
#
DEPTH = ../../..
topsrcdir = @top_srcdir@
srcdir = @srcdir@
VPATH = @srcdir@
include $(DEPTH)/config/autoconf.mk
DIRS = public src
include $(topsrcdir)/config/rules.mk

View File

@@ -0,0 +1,52 @@
#
# The contents of this file are subject to the Mozilla Public
# License Version 1.1 (the "License"); you may not use this file
# except in compliance with the License. You may obtain a copy of
# the License at http://www.mozilla.org/MPL/
#
# Software distributed under the License is distributed on an "AS
# IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
# implied. See the License for the specific language governing
# rights and limitations under the License.
#
# The Original Code is mozilla.org code.
#
# The Initial Developer of the Original Code is Netscape
# Communications Corporation. Portions created by Netscape are
# Copyright (C) 1998 Netscape Communications Corporation. All
# Rights Reserved.
#
# Contributor(s):
#
DEPTH = ../../../..
topsrcdir = @top_srcdir@
srcdir = @srcdir@
VPATH = @srcdir@
include $(DEPTH)/config/autoconf.mk
MODULE = xmlextras
LIBRARY_NAME = xmlextrassoap_s
REQUIRES = xpcom string caps dom js widget xpconnect necko schema
CPPSRCS = \
nsDefaultSOAPEncoder.cpp\
nsHTTPSOAPTransport.cpp \
nsSOAPCall.cpp \
nsSOAPEncoding.cpp \
nsSOAPFault.cpp \
nsSOAPHeaderBlock.cpp \
nsSOAPMessage.cpp \
nsSOAPParameter.cpp \
nsSOAPResponse.cpp \
nsSOAPUtils.cpp \
$(NULL)
# we don't want the shared lib, but we want to force the creation of a
# static lib.
FORCE_STATIC_LIB = 1
#override NO_SHARED_LIB=1
#override NO_STATIC_LIB=
include $(topsrcdir)/config/rules.mk

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,34 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Netscape 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/NPL/
*
* Software distributed under the License is distributed on an "AS
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
* implied. See the License for the specific language governing
* rights and limitations under the License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All
* Rights Reserved.
*
* Contributor(s):
*/
#ifndef nsDefaultSOAPEncoder_h__
#define nsDefaultSOAPEncoder_h__
#include "nsSOAPEncoding.h"
class nsDefaultSOAPEncoder : public nsSOAPEncoding
{
public:
nsDefaultSOAPEncoder();
};
#endif

View File

@@ -0,0 +1,196 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Netscape 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/NPL/
*
* Software distributed under the License is distributed on an "AS
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
* implied. See the License for the specific language governing
* rights and limitations under the License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All
* Rights Reserved.
*
* Contributor(s):
*/
#include "nsHTTPSOAPTransport.h"
#include "nsIComponentManager.h"
#include "nsIDOMDocument.h"
#include "nsString.h"
#include "nsSOAPUtils.h"
#include "nsSOAPCall.h"
#include "nsSOAPResponse.h"
#include "nsIDOMEventTarget.h"
nsHTTPSOAPTransport::nsHTTPSOAPTransport()
{
NS_INIT_ISUPPORTS();
}
nsHTTPSOAPTransport::~nsHTTPSOAPTransport()
{
}
NS_IMPL_ISUPPORTS1_CI(nsHTTPSOAPTransport, nsISOAPTransport)
/* void syncCall (in nsISOAPCall aCall, in nsISOAPResponse aResponse); */
NS_IMETHODIMP nsHTTPSOAPTransport::SyncCall(nsISOAPCall *aCall, nsISOAPResponse *aResponse)
{
NS_ENSURE_ARG(aCall);
nsresult rv;
nsCOMPtr<nsIXMLHttpRequest> request;
request = do_CreateInstance(NS_XMLHTTPREQUEST_CONTRACTID, &rv);
if (NS_FAILED(rv)) return rv;
nsAutoString action;
rv = aCall->GetActionURI(action);
if (NS_FAILED(rv)) return rv;
if (!AStringIsNull(action)) {
rv = request->SetRequestHeader("SOAPAction", NS_ConvertUCS2toUTF8(action).get());
if (NS_FAILED(rv)) return rv;
}
nsAutoString uri;
rv = aCall->GetTransportURI(uri);
if (NS_FAILED(rv)) return rv;
if (!AStringIsNull(uri)) return NS_ERROR_NOT_INITIALIZED;
nsCOMPtr<nsIDOMDocument> messageDocument;
rv = aCall->GetMessage(getter_AddRefs(messageDocument));
if (NS_FAILED(rv)) return rv;
if (!messageDocument) return NS_ERROR_NOT_INITIALIZED;
rv = request->OpenRequest("POST", NS_ConvertUCS2toUTF8(uri).get(), PR_FALSE, nsnull, nsnull);
if (NS_FAILED(rv)) return rv;
rv = request->Send(messageDocument);
if (NS_FAILED(rv)) return rv;
request->GetStatus(&rv);
if (NS_FAILED(rv)) return rv;
if (aResponse) {
nsCOMPtr<nsIDOMDocument> response;
rv = request->GetResponseXML(getter_AddRefs(response));
if (NS_FAILED(rv)) return rv;
rv = aResponse->SetMessage(response);
if (NS_FAILED(rv)) return rv;
}
return NS_OK;
}
class nsHTTPSOAPTransportCompletion : public nsIDOMEventListener
{
public:
nsHTTPSOAPTransportCompletion();
virtual ~nsHTTPSOAPTransportCompletion();
NS_DECL_ISUPPORTS
// nsIDOMEventListener
NS_IMETHOD HandleEvent(nsIDOMEvent* aEvent);
protected:
nsCOMPtr<nsISOAPCall> mCall;
nsCOMPtr<nsISOAPResponse> mResponse;
nsCOMPtr<nsIXMLHttpRequest> mRequest;
nsCOMPtr<nsISOAPResponseListener> mListener;
};
NS_IMPL_ISUPPORTS1(nsHTTPSOAPTransportCompletion, nsIDOMEventListener)
nsHTTPSOAPTransportCompletion::nsHTTPSOAPTransportCompletion()
{
NS_INIT_ISUPPORTS();
}
nsHTTPSOAPTransportCompletion::~nsHTTPSOAPTransportCompletion()
{
}
NS_IMETHODIMP
nsHTTPSOAPTransportCompletion::HandleEvent(nsIDOMEvent* aEvent)
{
nsresult rv;
mRequest->GetStatus(&rv);
if (NS_SUCCEEDED(rv)) {
nsCOMPtr<nsIDOMDocument> document;
rv = mRequest->GetResponseXML(getter_AddRefs(document));
if (NS_SUCCEEDED(rv)) {
rv = mResponse->SetMessage(document);
}
}
PRBool c; // In other transports, this may signal to stop returning if multiple returns
mListener->HandleResponse(mResponse, mCall, (PRInt32)rv, PR_TRUE, &c);
return NS_OK;
}
/* void asyncCall (in nsISOAPCall aCall, in nsISOAPResponseListener aListener, in nsISOAPResponse aResponse); */
NS_IMETHODIMP nsHTTPSOAPTransport::AsyncCall(nsISOAPCall *aCall, nsISOAPResponseListener *aListener, nsISOAPResponse *aResponse)
{
NS_ENSURE_ARG(aCall);
nsresult rv;
nsCOMPtr<nsIXMLHttpRequest> request;
nsCOMPtr<nsIDOMEventTarget> eventTarget = do_QueryInterface(request, &rv);
if (NS_FAILED(rv)) return rv;
request = do_CreateInstance(NS_XMLHTTPREQUEST_CONTRACTID, &rv);
if (NS_FAILED(rv)) return rv;
nsAutoString action;
rv = aCall->GetActionURI(action);
if (NS_FAILED(rv)) return rv;
if (!AStringIsNull(action)) {
rv = request->SetRequestHeader("SOAPAction", NS_ConvertUCS2toUTF8(action).get());
if (NS_FAILED(rv)) return rv;
}
nsCOMPtr<nsIDOMEventListener> listener = new nsHTTPSOAPTransportCompletion();
if (!listener) return NS_ERROR_OUT_OF_MEMORY;
nsAutoString uri;
rv = aCall->GetTransportURI(uri);
if (NS_FAILED(rv)) return rv;
if (!AStringIsNull(uri)) return NS_ERROR_NOT_INITIALIZED;
nsCOMPtr<nsIDOMDocument> messageDocument;
rv = aCall->GetMessage(getter_AddRefs(messageDocument));
if (NS_FAILED(rv)) return rv;
if (!messageDocument) return NS_ERROR_NOT_INITIALIZED;
rv = request->OpenRequest("POST", NS_ConvertUCS2toUTF8(uri).get(), PR_TRUE, nsnull, nsnull);
if (NS_FAILED(rv)) return rv;
rv = request->Send(messageDocument);
if (NS_FAILED(rv)) return rv;
eventTarget->AddEventListener(NS_LITERAL_STRING("load"), listener, PR_FALSE);
eventTarget->AddEventListener(NS_LITERAL_STRING("error"), listener, PR_FALSE);
rv = request->Send(messageDocument);
if (NS_FAILED(rv)) return rv;
return NS_OK;
}
/* void addListener (in nsISOAPTransportListener aListener, in boolean aCapture); */
NS_IMETHODIMP nsHTTPSOAPTransport::AddListener(nsISOAPTransportListener *aListener, PRBool aCapture)
{
return NS_ERROR_NOT_IMPLEMENTED;
}
/* void removeListener (in nsISOAPTransportListener aListener, in boolean aCapture); */
NS_IMETHODIMP nsHTTPSOAPTransport::RemoveListener(nsISOAPTransportListener *aListener, PRBool aCapture)
{
return NS_ERROR_NOT_IMPLEMENTED;
}

View File

@@ -0,0 +1,50 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Netscape 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/NPL/
*
* Software distributed under the License is distributed on an "AS
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
* implied. See the License for the specific language governing
* rights and limitations under the License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All
* Rights Reserved.
*
* Contributor(s):
*/
#ifndef nsHTTPSOAPTransport_h__
#define nsHTTPSOAPTransport_h__
#include "nsISOAPTransport.h"
#include "nsIXMLHttpRequest.h"
#include "nsIDOMEventListener.h"
#include "nsISOAPTransportListener.h"
#include "nsCOMPtr.h"
class nsHTTPSOAPTransport : public nsISOAPTransport
{
public:
nsHTTPSOAPTransport();
virtual ~nsHTTPSOAPTransport();
NS_DECL_ISUPPORTS
// nsISOAPTransport
NS_DECL_NSISOAPTRANSPORT
};
#define NS_HTTPSOAPTRANSPORT_CID \
{ /* d852ade0-5823-11d4-9a62-00104bdf5339 */ \
0xd852ade0, 0x5823, 0x11d4, \
{0x9a, 0x62, 0x00, 0x10, 0x4b, 0xdf, 0x53, 0x39} }
#define NS_HTTPSOAPTRANSPORT_CONTRACTID NS_SOAPTRANSPORT_CONTRACTID_PREFIX "http"
#endif

View File

@@ -0,0 +1,187 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Netscape 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/NPL/
*
* Software distributed under the License is distributed on an "AS
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
* implied. See the License for the specific language governing
* rights and limitations under the License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All
* Rights Reserved.
*
* Contributor(s):
*/
#include "nsSOAPCall.h"
#include "nsSOAPResponse.h"
#include "nsSOAPUtils.h"
#include "nsISOAPTransport.h"
#include "nsIServiceManager.h"
#include "nsIComponentManager.h"
#include "nsIURI.h"
#include "nsNetUtil.h"
/////////////////////////////////////////////
//
//
/////////////////////////////////////////////
nsSOAPCall::nsSOAPCall()
{
}
nsSOAPCall::~nsSOAPCall()
{
}
NS_IMPL_CI_INTERFACE_GETTER2(nsSOAPCall, nsISOAPMessage, nsISOAPCall)
NS_IMPL_ADDREF_INHERITED(nsSOAPCall, nsSOAPMessage)
NS_IMPL_RELEASE_INHERITED(nsSOAPCall, nsSOAPMessage)
NS_INTERFACE_MAP_BEGIN(nsSOAPCall)
NS_INTERFACE_MAP_ENTRY(nsISOAPCall)
NS_IMPL_QUERY_CLASSINFO(nsSOAPCall)
NS_INTERFACE_MAP_END_INHERITING(nsSOAPMessage)
/* attribute DOMString transportURI; */
NS_IMETHODIMP nsSOAPCall::GetTransportURI(nsAWritableString & aTransportURI)
{
NS_ENSURE_ARG_POINTER(&aTransportURI);
aTransportURI.Assign(mTransportURI);
return NS_OK;
}
NS_IMETHODIMP nsSOAPCall::SetTransportURI(const nsAReadableString & aTransportURI)
{
mTransportURI.Assign(aTransportURI);
return NS_OK;
}
nsresult
nsSOAPCall::GetTransport(nsISOAPTransport** aTransport)
{
NS_ENSURE_ARG_POINTER(aTransport);
nsresult rv;
nsCOMPtr<nsIURI> uri;
nsXPIDLCString protocol;
nsCString transportURI(ToNewCString(mTransportURI));
rv = NS_NewURI(getter_AddRefs(uri), transportURI.get());
if (NS_FAILED(rv)) return rv;
uri->GetScheme(getter_Copies(protocol));
nsCAutoString transportContractid;
transportContractid.Assign(NS_SOAPTRANSPORT_CONTRACTID_PREFIX);
transportContractid.Append(protocol);
nsCOMPtr<nsISOAPTransport> transport = do_GetService(transportContractid.get(), &rv);
if (NS_FAILED(rv)) return rv;
*aTransport = transport.get();
NS_ADDREF(*aTransport);
return NS_OK;
}
/* nsISOAPResponse invoke (); */
NS_IMETHODIMP nsSOAPCall::Invoke(nsISOAPResponse **_retval)
{
NS_ENSURE_ARG_POINTER(_retval);
nsresult rv;
nsCOMPtr<nsISOAPTransport> transport;
if (mTransportURI.Length() == 0) {
return NS_ERROR_NOT_INITIALIZED;
}
rv = GetTransport(getter_AddRefs(transport));
if (NS_FAILED(rv)) return rv;
nsCOMPtr<nsISOAPResponse> response;
response = new nsSOAPResponse();
if (!response) return NS_ERROR_OUT_OF_MEMORY;
rv = response->SetEncoding(mEncoding);
if (NS_FAILED(rv)) return rv;
rv = transport->SyncCall(this, response);
if (NS_FAILED(rv)) return rv;
return response->QueryInterface(NS_GET_IID(nsISOAPResponse), (void**)_retval);
}
/* void asyncInvoke (in nsISOAPResponseListener listener); */
NS_IMETHODIMP nsSOAPCall::AsyncInvoke(nsISOAPResponseListener *listener)
{
nsresult rv;
nsCOMPtr<nsISOAPTransport> transport;
if (mTransportURI.Length() == 0) {
return NS_ERROR_NOT_INITIALIZED;
}
rv = GetTransport(getter_AddRefs(transport));
if (NS_FAILED(rv)) return rv;
nsCOMPtr<nsISOAPResponse> response;
response = new nsSOAPResponse();
if (!response) return NS_ERROR_OUT_OF_MEMORY;
rv = response->SetEncoding(mEncoding);
if (NS_FAILED(rv)) return rv;
rv = transport->AsyncCall(this, listener, response);
return rv;
}
static const char* kAllAccess = "AllAccess";
/* string canCreateWrapper (in nsIIDPtr iid); */
NS_IMETHODIMP
nsSOAPCall::CanCreateWrapper(const nsIID * iid, char **_retval)
{
if (iid->Equals(NS_GET_IID(nsISOAPCall))) {
*_retval = nsCRT::strdup(kAllAccess);
}
return NS_OK;
}
/* string canCallMethod (in nsIIDPtr iid, in wstring methodName); */
NS_IMETHODIMP
nsSOAPCall::CanCallMethod(const nsIID * iid, const PRUnichar *methodName, char **_retval)
{
if (iid->Equals(NS_GET_IID(nsISOAPCall))) {
*_retval = nsCRT::strdup(kAllAccess);
}
return NS_OK;
}
/* string canGetProperty (in nsIIDPtr iid, in wstring propertyName); */
NS_IMETHODIMP
nsSOAPCall::CanGetProperty(const nsIID * iid, const PRUnichar *propertyName, char **_retval)
{
if (iid->Equals(NS_GET_IID(nsISOAPCall))) {
*_retval = nsCRT::strdup(kAllAccess);
}
return NS_OK;
}
/* string canSetProperty (in nsIIDPtr iid, in wstring propertyName); */
NS_IMETHODIMP
nsSOAPCall::CanSetProperty(const nsIID * iid, const PRUnichar *propertyName, char **_retval)
{
if (iid->Equals(NS_GET_IID(nsISOAPCall))) {
*_retval = nsCRT::strdup(kAllAccess);
}
return NS_OK;
}

View File

@@ -0,0 +1,58 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Netscape 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/NPL/
*
* Software distributed under the License is distributed on an "AS
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
* implied. See the License for the specific language governing
* rights and limitations under the License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All
* Rights Reserved.
*
* Contributor(s):
*/
#ifndef nsSOAPCall_h__
#define nsSOAPCall_h__
#include "nsString.h"
#include "nsSOAPMessage.h"
#include "nsISOAPCall.h"
#include "nsISecurityCheckedComponent.h"
#include "nsISOAPTransport.h"
#include "nsISOAPResponseListener.h"
#include "nsCOMPtr.h"
class nsSOAPCall : public nsSOAPMessage,
public nsISOAPCall
{
public:
nsSOAPCall();
virtual ~nsSOAPCall();
NS_DECL_ISUPPORTS
// nsISOAPCall
NS_FORWARD_NSISOAPMESSAGE(nsSOAPMessage::)
// nsISOAPCall
NS_DECL_NSISOAPCALL
// nsISecurityCheckedComponent
NS_DECL_NSISECURITYCHECKEDCOMPONENT
protected:
nsString mTransportURI;
nsresult GetTransport(nsISOAPTransport** aTransport);
};
#endif

View File

@@ -0,0 +1,405 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Netscape 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/NPL/
*
* Software distributed under the License is distributed on an "AS
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
* implied. See the License for the specific language governing
* rights and limitations under the License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All
* Rights Reserved.
*
* Contributor(s):
*/
#include "nsString.h"
#include "nsISOAPParameter.h"
#include "nsSOAPMessage.h"
#include "nsISOAPEncoder.h"
#include "nsISOAPDecoder.h"
#include "nsSOAPEncoding.h"
#include "nsSOAPUtils.h"
#include "nsIServiceManager.h"
#include "nsIComponentManager.h"
#include "nsIDOMNodeList.h"
#include "nsISchema.h"
#include "nsISchemaLoader.h"
#include "nsSOAPUtils.h"
// First comes the registry which shares between associated encodings but is never seen by xpconnect.
NS_IMPL_ISUPPORTS1(nsSOAPEncodingRegistry,nsISOAPEncoding)
nsSOAPEncodingRegistry::nsSOAPEncodingRegistry(nsISOAPEncoding* aEncoding): mEncodings(new nsSupportsHashtable)
{
NS_INIT_ISUPPORTS();
nsAutoString style;
aEncoding->GetStyleURI(style);
nsStringKey styleKey(style);
mEncodings->Put(&styleKey, aEncoding);
/* member initializers and constructor code */
}
nsSOAPEncodingRegistry::~nsSOAPEncodingRegistry()
{
/* destructor code */
delete mEncodings;
}
nsresult nsSOAPEncodingRegistry::GetStyle(const nsAString& aStyleURI, PRBool aCreateIf, nsISOAPEncoding* * aEncoding)
{
NS_SOAP_ENSURE_ARG_STRING(aStyleURI);
NS_ENSURE_ARG_POINTER(aEncoding);
nsStringKey styleKey(aStyleURI);
*aEncoding = (nsISOAPEncoding*)mEncodings->Get(&styleKey);
if (!*aEncoding)
{
nsCOMPtr<nsISOAPEncoding> defaultEncoding;
nsCAutoString encodingContractid;
encodingContractid.Assign(NS_SOAPENCODING_CONTRACTID_PREFIX);
encodingContractid.Append(NS_ConvertUCS2toUTF8(aStyleURI));
defaultEncoding = do_GetService(encodingContractid.get());
if (defaultEncoding || aCreateIf) {
*aEncoding = new nsSOAPEncoding(aStyleURI, this, defaultEncoding);
mEncodings->Put(&styleKey, *aEncoding);
}
}
return NS_OK;
}
nsresult nsSOAPEncodingRegistry::SetSchemaCollection(nsISchemaCollection* aSchemaCollection)
{
NS_ENSURE_ARG(aSchemaCollection);
mSchemaCollection = aSchemaCollection;
return NS_OK;
}
nsresult nsSOAPEncodingRegistry::GetSchemaCollection(nsISchemaCollection** aSchemaCollection)
{
NS_ENSURE_ARG_POINTER(aSchemaCollection);
if (!mSchemaCollection) {
nsresult rv;
nsCOMPtr<nsISchemaLoader>loader = do_CreateInstance(NS_SCHEMALOADER_CONTRACTID, &rv);
if (NS_FAILED(rv)) return rv;
mSchemaCollection = do_QueryInterface(loader);
if (!mSchemaCollection) return NS_ERROR_FAILURE;
}
*aSchemaCollection = mSchemaCollection;
NS_ADDREF(*aSchemaCollection);
return NS_OK;
}
/* readonly attribute AString styleURI; */
NS_IMETHODIMP nsSOAPEncodingRegistry::GetStyleURI(nsAString & aStyleURI)
{
return NS_ERROR_NOT_IMPLEMENTED;
}
/* nsISOAPEncoder setEncoder (in AString aSchemaNamespaceURI, in AString aSchemaType, in nsISOAPEncoder aEncoder); */
NS_IMETHODIMP nsSOAPEncodingRegistry::SetEncoder(const nsAString & aSchemaNamespaceURI, const nsAString & aSchemaType, nsISOAPEncoder *aEncoder)
{
return NS_ERROR_NOT_IMPLEMENTED;
}
/* nsISOAPEncoder getEncoder (in AString aSchemaNamespaceURI, in AString aSchemaType); */
NS_IMETHODIMP nsSOAPEncodingRegistry::GetEncoder(const nsAString & aSchemaNamespaceURI, const nsAString & aSchemaType, nsISOAPEncoder **_retval)
{
return NS_ERROR_NOT_IMPLEMENTED;
}
/* nsISOAPDecoder setDecoder (in AString aSchemaNamespaceURI, in AString aSchemaType, in nsISOAPDecoder aDecoder); */
NS_IMETHODIMP nsSOAPEncodingRegistry::SetDecoder(const nsAString & aSchemaNamespaceURI, const nsAString & aSchemaType, nsISOAPDecoder *aDecoder)
{
return NS_ERROR_NOT_IMPLEMENTED;
}
/* nsISOAPDecoder getDecoder (in AString aSchemaNamespaceURI, in AString aSchemaType); */
NS_IMETHODIMP nsSOAPEncodingRegistry::GetDecoder(const nsAString & aSchemaNamespaceURI, const nsAString & aSchemaType, nsISOAPDecoder **_retval)
{
return NS_ERROR_NOT_IMPLEMENTED;
}
/* attribute nsISOAPEncoder defaultEncoder; */
NS_IMETHODIMP nsSOAPEncodingRegistry::GetDefaultEncoder(nsISOAPEncoder * *aDefaultEncoder)
{
return NS_ERROR_NOT_IMPLEMENTED;
}
NS_IMETHODIMP nsSOAPEncodingRegistry::SetDefaultEncoder(nsISOAPEncoder * aDefaultEncoder)
{
return NS_ERROR_NOT_IMPLEMENTED;
}
/* attribute nsISOAPDecoder defaultDecoder; */
NS_IMETHODIMP nsSOAPEncodingRegistry::GetDefaultDecoder(nsISOAPDecoder * *aDefaultDecoder)
{
return NS_ERROR_NOT_IMPLEMENTED;
}
NS_IMETHODIMP nsSOAPEncodingRegistry::SetDefaultDecoder(nsISOAPDecoder * aDefaultDecoder)
{
return NS_ERROR_NOT_IMPLEMENTED;
}
/* nsIDOMElement encode (in nsIVariant aSource, in AString aNamespaceURI, in AString aName, in nsISchemaType aSchemaType, in nsISOAPAttachments aAttachments, in nsIDOMElement aDestination); */
NS_IMETHODIMP nsSOAPEncodingRegistry::Encode(nsIVariant *aSource, const nsAString & aNamespaceURI, const nsAString & aName, nsISchemaType *aSchemaType, nsISOAPAttachments *aAttachments, nsIDOMElement *aDestination, nsIDOMElement **_retval)
{
return NS_ERROR_NOT_IMPLEMENTED;
}
/* nsIVariant decode (in nsIDOMElement aSource, in nsISchemaType aSchemaType, in nsISOAPAttachments aAttachments); */
NS_IMETHODIMP nsSOAPEncodingRegistry::Decode(nsIDOMElement *aSource, nsISchemaType *aSchemaType, nsISOAPAttachments *aAttachments, nsIVariant **_retval)
{
return NS_ERROR_NOT_IMPLEMENTED;
}
// Second, we create the encodings themselves.
NS_IMPL_ISUPPORTS2(nsSOAPEncoding, nsISOAPEncoding, nsISecurityCheckedComponent)
nsSOAPEncoding::nsSOAPEncoding(): mEncoders(new nsSupportsHashtable),
mDecoders(new nsSupportsHashtable)
{
NS_INIT_ISUPPORTS();
/* member initializers and constructor code */
mStyleURI.Assign(nsSOAPUtils::kSOAPEncodingURI);
mDefaultEncoding = do_GetService(NS_DEFAULTSOAPENCODER_CONTRACTID);
mRegistry = new nsSOAPEncodingRegistry(this);
}
nsSOAPEncoding::nsSOAPEncoding(const nsAString& aStyleURI, nsSOAPEncodingRegistry* aRegistry, nsISOAPEncoding* aDefaultEncoding)
: mEncoders(new nsSupportsHashtable), mDecoders(new nsSupportsHashtable)
{
NS_INIT_ISUPPORTS();
/* member initializers and constructor code */
mStyleURI.Assign(aStyleURI);
mRegistry = aRegistry;
mDefaultEncoding = aDefaultEncoding;
}
nsSOAPEncoding::~nsSOAPEncoding()
{
/* destructor code */
delete mEncoders;
delete mDecoders;
}
nsresult nsSOAPEncoding::SetSchemaCollection(nsISchemaCollection* aSchemaCollection)
{
NS_ENSURE_ARG(aSchemaCollection);
return mRegistry->SetSchemaCollection(aSchemaCollection);
}
nsresult nsSOAPEncoding::GetSchemaCollection(nsISchemaCollection** aSchemaCollection)
{
NS_ENSURE_ARG_POINTER(aSchemaCollection);
return mRegistry->GetSchemaCollection(aSchemaCollection);
}
/* readonly attribute AString styleURI; */
NS_IMETHODIMP nsSOAPEncoding::GetStyleURI(nsAString & aStyleURI)
{
NS_SOAP_ENSURE_ARG_STRING(aStyleURI);
aStyleURI.Assign(mStyleURI);
return NS_OK;
}
/* nsISOAPEncoding getStyle (in AString aStyleURI, in boolean aCreateIf); */
NS_IMETHODIMP nsSOAPEncoding::GetStyle(const nsAString & aStyleURI, PRBool aCreateIf, nsISOAPEncoding **_retval)
{
NS_SOAP_ENSURE_ARG_STRING(aStyleURI);
NS_ENSURE_ARG_POINTER(_retval);
return mRegistry->GetStyle(aStyleURI, aCreateIf, _retval);
}
/* nsISOAPEncoder setEncoder (in AString aSchemaNamespaceURI, in AString aSchemaType, in nsISOAPEncoder aEncoder); */
NS_IMETHODIMP nsSOAPEncoding::SetEncoder(const nsAString & aSchemaNamespaceURI, const nsAString & aSchemaType, nsISOAPEncoder *aEncoder)
{
NS_SOAP_ENSURE_ARG_STRING(aSchemaNamespaceURI);
NS_SOAP_ENSURE_ARG_STRING(aSchemaType);
NS_ENSURE_ARG(aEncoder);
nsAutoString name(aSchemaNamespaceURI);
name.Append(nsSOAPUtils::kEncodingSeparator);
name.Append(aSchemaType);
nsStringKey nameKey(name);
if (aEncoder) {
mEncoders->Put(&nameKey, aEncoder, nsnull);
}
else {
mEncoders->Remove(&nameKey, nsnull);
}
return NS_OK;
}
/* nsISOAPEncoder getEncoder (in AString aSchemaNamespaceURI, in AString aSchemaType); */
NS_IMETHODIMP nsSOAPEncoding::GetEncoder(const nsAString & aSchemaNamespaceURI, const nsAString & aSchemaType, nsISOAPEncoder **_retval)
{
NS_SOAP_ENSURE_ARG_STRING(aSchemaNamespaceURI);
NS_SOAP_ENSURE_ARG_STRING(aSchemaType);
NS_ENSURE_ARG_POINTER(_retval);
nsAutoString name(aSchemaNamespaceURI);
name.Append(nsSOAPUtils::kEncodingSeparator);
name.Append(aSchemaType);
nsStringKey nameKey(name);
*_retval = (nsISOAPEncoder*)mEncoders->Get(&nameKey);
if (*_retval == nsnull && mDefaultEncoding != nsnull) {
return mDefaultEncoding->GetEncoder(aSchemaNamespaceURI, aSchemaType, _retval);
}
return NS_OK;
}
/* nsISOAPDecoder setDecoder (in AString aSchemaNamespaceURI, in AString aSchemaType, in nsISOAPDecoder aDecoder); */
NS_IMETHODIMP nsSOAPEncoding::SetDecoder(const nsAString & aSchemaNamespaceURI, const nsAString & aSchemaType, nsISOAPDecoder *aDecoder)
{
NS_SOAP_ENSURE_ARG_STRING(aSchemaNamespaceURI);
NS_SOAP_ENSURE_ARG_STRING(aSchemaType);
nsAutoString name(aSchemaNamespaceURI);
name.Append(nsSOAPUtils::kEncodingSeparator);
name.Append(aSchemaType);
nsStringKey nameKey(name);
if (aDecoder) {
mDecoders->Put(&nameKey, aDecoder, nsnull);
}
else {
mDecoders->Remove(&nameKey, nsnull);
}
return NS_OK;
}
/* nsISOAPDecoder getDecoder (in AString aSchemaNamespaceURI, in AString aSchemaType); */
NS_IMETHODIMP nsSOAPEncoding::GetDecoder(const nsAString & aSchemaNamespaceURI, const nsAString & aSchemaType, nsISOAPDecoder **_retval)
{
NS_SOAP_ENSURE_ARG_STRING(aSchemaNamespaceURI);
NS_SOAP_ENSURE_ARG_STRING(aSchemaType);
NS_ENSURE_ARG_POINTER(_retval);
nsAutoString name(aSchemaNamespaceURI);
name.Append(nsSOAPUtils::kEncodingSeparator);
name.Append(aSchemaType);
nsStringKey nameKey(name);
*_retval = (nsISOAPDecoder*)mDecoders->Get(&nameKey);
if (*_retval == nsnull && mDefaultEncoding != nsnull) {
return mDefaultEncoding->GetDecoder(aSchemaNamespaceURI, aSchemaType, _retval);
}
return NS_OK;
}
/* nsIDOMElement encode (in nsIVariant aSource, in AString aNamespaceURI, in AString aName, in nsISchemaType aSchemaType, in nsISOAPAttachments aAttachments, in nsIDOMElement aDestination); */
NS_IMETHODIMP nsSOAPEncoding::Encode(nsIVariant *aSource, const nsAString & aNamespaceURI, const nsAString & aName, nsISchemaType *aSchemaType, nsISOAPAttachments *aAttachments, nsIDOMElement *aDestination, nsIDOMElement **_retval)
{
NS_ENSURE_ARG(aSource);
NS_ENSURE_ARG_POINTER(_retval);
nsCOMPtr<nsISOAPEncoder> encoder;
nsresult rv = GetDefaultEncoder(getter_AddRefs(encoder));
if (NS_FAILED(rv)) return rv;
if (encoder) {
return encoder->Encode(this, aSource, aNamespaceURI, aName, aSchemaType, aAttachments, aDestination,
_retval);
}
*_retval = nsnull;
return NS_ERROR_NOT_IMPLEMENTED;
}
/* nsIVariant decode (in nsIDOMElement aSource, in nsISchemaType aSchemaType, in nsISOAPAttachments aAttachments); */
NS_IMETHODIMP nsSOAPEncoding::Decode(nsIDOMElement *aSource, nsISchemaType *aSchemaType, nsISOAPAttachments *aAttachments, nsIVariant **_retval)
{
NS_ENSURE_ARG(aSource);
NS_ENSURE_ARG_POINTER(_retval);
nsCOMPtr<nsISOAPDecoder> decoder;
nsresult rv = GetDefaultDecoder(getter_AddRefs(decoder));
if (NS_FAILED(rv)) return rv;
if (decoder) {
return decoder->Decode(this, aSource, aSchemaType, aAttachments, _retval);
}
*_retval = nsnull;
return NS_ERROR_NOT_IMPLEMENTED;
}
/* attribute nsISOAPEncoder defaultEncoder; */
NS_IMETHODIMP nsSOAPEncoding::GetDefaultEncoder(nsISOAPEncoder * *aDefaultEncoder)
{
NS_ENSURE_ARG_POINTER(aDefaultEncoder);
if (mDefaultEncoding && !mDefaultEncoder) {
return mDefaultEncoding->GetDefaultEncoder(aDefaultEncoder);
}
*aDefaultEncoder = mDefaultEncoder;
NS_IF_ADDREF(*aDefaultEncoder);
return NS_OK;
}
NS_IMETHODIMP nsSOAPEncoding::SetDefaultEncoder(nsISOAPEncoder * aDefaultEncoder)
{
mDefaultEncoder = aDefaultEncoder;
return NS_OK;
}
/* attribute nsISOAPDecoder defaultDecoder; */
NS_IMETHODIMP nsSOAPEncoding::GetDefaultDecoder(nsISOAPDecoder * *aDefaultDecoder)
{
NS_ENSURE_ARG_POINTER(aDefaultDecoder);
if (mDefaultEncoding && !mDefaultDecoder) {
return mDefaultEncoding->GetDefaultDecoder(aDefaultDecoder);
}
*aDefaultDecoder = mDefaultDecoder;
NS_IF_ADDREF(*aDefaultDecoder);
return NS_OK;
return NS_ERROR_NOT_IMPLEMENTED;
}
NS_IMETHODIMP nsSOAPEncoding::SetDefaultDecoder(nsISOAPDecoder * aDefaultDecoder)
{
mDefaultDecoder = aDefaultDecoder;
return NS_OK;
}
static const char* kAllAccess = "AllAccess";
/* string canCreateWrapper (in nsIIDPtr iid); */
NS_IMETHODIMP
nsSOAPEncoding::CanCreateWrapper(const nsIID * iid, char **_retval)
{
if (iid->Equals(NS_GET_IID(nsISOAPEncoding))) {
*_retval = nsCRT::strdup(kAllAccess);
}
return NS_OK;
}
/* string canCallMethod (in nsIIDPtr iid, in wstring methodName); */
NS_IMETHODIMP
nsSOAPEncoding::CanCallMethod(const nsIID * iid, const PRUnichar *methodName, char **_retval)
{
if (iid->Equals(NS_GET_IID(nsISOAPEncoding))) {
*_retval = nsCRT::strdup(kAllAccess);
}
return NS_OK;
}
/* string canGetProperty (in nsIIDPtr iid, in wstring propertyName); */
NS_IMETHODIMP
nsSOAPEncoding::CanGetProperty(const nsIID * iid, const PRUnichar *propertyName, char **_retval)
{
if (iid->Equals(NS_GET_IID(nsISOAPEncoding))) {
*_retval = nsCRT::strdup(kAllAccess);
}
return NS_OK;
}
/* string canSetProperty (in nsIIDPtr iid, in wstring propertyName); */
NS_IMETHODIMP
nsSOAPEncoding::CanSetProperty(const nsIID * iid, const PRUnichar *propertyName, char **_retval)
{
if (iid->Equals(NS_GET_IID(nsISOAPEncoding))) {
*_retval = nsCRT::strdup(kAllAccess);
}
return NS_OK;
}

View File

@@ -0,0 +1,77 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Netscape 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/NPL/
*
* Software distributed under the License is distributed on an "AS
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
* implied. See the License for the specific language governing
* rights and limitations under the License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All
* Rights Reserved.
*
* Contributor(s):
*/
#ifndef nsSOAPEncodingRegistry_h__
#define nsSOAPEncodingRegistry_h__
#include "nsString.h"
#include "nsISecurityCheckedComponent.h"
#include "nsIDOMElement.h"
#include "nsISOAPEncoding.h"
#include "nsISOAPEncoder.h"
#include "nsISOAPDecoder.h"
#include "nsCOMPtr.h"
#include "nsHashtable.h"
#include "nsISchema.h"
class nsSOAPEncoding;
/* Header file */
class nsSOAPEncodingRegistry : public nsISOAPEncoding
{
public:
NS_DECL_ISUPPORTS
NS_DECL_NSISOAPENCODING
nsSOAPEncodingRegistry() {}
nsSOAPEncodingRegistry(nsISOAPEncoding* aEncoding);
virtual ~nsSOAPEncodingRegistry();
protected:
nsSupportsHashtable* mEncodings;
nsCOMPtr<nsISchemaCollection> mSchemaCollection;
};
class nsSOAPEncoding : public nsISOAPEncoding,
public nsISecurityCheckedComponent
{
public:
NS_DECL_ISUPPORTS
NS_DECL_NSISOAPENCODING
// nsISecurityCheckedComponent
NS_DECL_NSISECURITYCHECKEDCOMPONENT
nsSOAPEncoding();
nsSOAPEncoding(const nsAString& aStyleURI, nsSOAPEncodingRegistry * aRegistry, nsISOAPEncoding* aDefaultEncoding);
virtual ~nsSOAPEncoding();
/* additional members */
protected:
nsString mStyleURI;
nsSupportsHashtable* mEncoders;
nsSupportsHashtable* mDecoders;
nsCOMPtr<nsISOAPEncoding> mRegistry;
nsCOMPtr<nsISOAPEncoding> mDefaultEncoding;
nsCOMPtr<nsISOAPEncoder> mDefaultEncoder;
nsCOMPtr<nsISOAPDecoder> mDefaultDecoder;
};
#endif

View File

@@ -0,0 +1,154 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Netscape 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/NPL/
*
* Software distributed under the License is distributed on an "AS
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
* implied. See the License for the specific language governing
* rights and limitations under the License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All
* Rights Reserved.
*
* Contributor(s):
*/
#include "nsSOAPFault.h"
#include "nsSOAPUtils.h"
#include "nsIDOMNodeList.h"
nsSOAPFault::nsSOAPFault(nsIDOMElement* aElement)
{
NS_INIT_ISUPPORTS();
mFaultElement = aElement;
}
nsSOAPFault::~nsSOAPFault()
{
}
NS_IMPL_ISUPPORTS2(nsSOAPFault, nsISOAPFault, nsISecurityCheckedComponent)
/* attribute nsIDOMElement element; */
NS_IMETHODIMP nsSOAPFault::SetElement(nsIDOMElement *aElement)
{
mFaultElement = aElement;
return NS_OK;
}
NS_IMETHODIMP nsSOAPFault::GetElement(nsIDOMElement * *aElement)
{
NS_ENSURE_ARG_POINTER(aElement);
*aElement = mFaultElement;
NS_IF_ADDREF(*aElement);
return NS_OK;
}
/* readonly attribute wstring faultCode; */
NS_IMETHODIMP nsSOAPFault::GetFaultCode(nsAWritableString & aFaultCode)
{
NS_ENSURE_ARG_POINTER(&aFaultCode);
aFaultCode.Truncate();
nsCOMPtr<nsIDOMElement> faultcode;
nsSOAPUtils::GetSpecificChildElement(mFaultElement,
nsSOAPUtils::kSOAPEnvURI,
nsSOAPUtils::kFaultCodeTagName,
getter_AddRefs(faultcode));
if (faultcode) {
nsSOAPUtils::GetElementTextContent(faultcode, aFaultCode);
}
return NS_OK;
}
/* readonly attribute wstring faultString; */
NS_IMETHODIMP nsSOAPFault::GetFaultString(nsAWritableString & aFaultString)
{
NS_ENSURE_ARG_POINTER(&aFaultString);
aFaultString.Truncate();
nsCOMPtr<nsIDOMElement> element;
nsSOAPUtils::GetSpecificChildElement(mFaultElement, nsSOAPUtils::kSOAPEnvURI,
nsSOAPUtils::kFaultStringTagName, getter_AddRefs(element));
if (element) {
nsSOAPUtils::GetElementTextContent(element, aFaultString);
}
return NS_OK;
}
/* readonly attribute wstring faultActor; */
NS_IMETHODIMP nsSOAPFault::GetFaultActor(nsAWritableString & aFaultActor)
{
NS_ENSURE_ARG_POINTER(&aFaultActor);
aFaultActor.Truncate();
nsCOMPtr<nsIDOMElement> element;
nsSOAPUtils::GetSpecificChildElement(mFaultElement, nsSOAPUtils::kSOAPEnvURI,
nsSOAPUtils::kFaultActorTagName, getter_AddRefs(element));
if (element) {
nsSOAPUtils::GetElementTextContent(element, aFaultActor);
}
return NS_OK;
}
/* readonly attribute nsIDOMElement detail; */
NS_IMETHODIMP nsSOAPFault::GetDetail(nsIDOMElement * *aDetail)
{
NS_ENSURE_ARG_POINTER(aDetail);
nsCOMPtr<nsIDOMElement> element;
nsSOAPUtils::GetSpecificChildElement(mFaultElement, nsSOAPUtils::kSOAPEnvURI,
nsSOAPUtils::kFaultDetailTagName, aDetail);
return NS_OK;
}
static const char* kAllAccess = "AllAccess";
/* string canCreateWrapper (in nsIIDPtr iid); */
NS_IMETHODIMP
nsSOAPFault::CanCreateWrapper(const nsIID * iid, char **_retval)
{
if (iid->Equals(NS_GET_IID(nsISOAPFault))) {
*_retval = nsCRT::strdup(kAllAccess);
}
return NS_OK;
}
/* string canCallMethod (in nsIIDPtr iid, in wstring methodName); */
NS_IMETHODIMP
nsSOAPFault::CanCallMethod(const nsIID * iid, const PRUnichar *methodName, char **_retval)
{
if (iid->Equals(NS_GET_IID(nsISOAPFault))) {
*_retval = nsCRT::strdup(kAllAccess);
}
return NS_OK;
}
/* string canGetProperty (in nsIIDPtr iid, in wstring propertyName); */
NS_IMETHODIMP
nsSOAPFault::CanGetProperty(const nsIID * iid, const PRUnichar *propertyName, char **_retval)
{
if (iid->Equals(NS_GET_IID(nsISOAPFault))) {
*_retval = nsCRT::strdup(kAllAccess);
}
return NS_OK;
}
/* string canSetProperty (in nsIIDPtr iid, in wstring propertyName); */
NS_IMETHODIMP
nsSOAPFault::CanSetProperty(const nsIID * iid, const PRUnichar *propertyName, char **_retval)
{
if (iid->Equals(NS_GET_IID(nsISOAPFault))) {
*_retval = nsCRT::strdup(kAllAccess);
}
return NS_OK;
}

View File

@@ -0,0 +1,51 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Netscape 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/NPL/
*
* Software distributed under the License is distributed on an "AS
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
* implied. See the License for the specific language governing
* rights and limitations under the License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All
* Rights Reserved.
*
* Contributor(s):
*/
#ifndef nsSOAPFault_h__
#define nsSOAPFault_h__
#include "nsString.h"
#include "nsISOAPFault.h"
#include "nsISecurityCheckedComponent.h"
#include "nsIDOMElement.h"
#include "nsCOMPtr.h"
class nsSOAPFault : public nsISOAPFault,
public nsISecurityCheckedComponent
{
public:
nsSOAPFault(nsIDOMElement* aElement);
virtual ~nsSOAPFault();
NS_DECL_ISUPPORTS
// nsISOAPFault
NS_DECL_NSISOAPFAULT
// nsISecurityCheckedComponent
NS_DECL_NSISECURITYCHECKEDCOMPONENT
protected:
nsCOMPtr<nsIDOMElement> mFaultElement;
};
#endif

View File

@@ -0,0 +1,297 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Netscape 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/NPL/
*
* Software distributed under the License is distributed on an "AS
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
* implied. See the License for the specific language governing
* rights and limitations under the License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All
* Rights Reserved.
*
* Contributor(s):
*/
#include "nsString.h"
#include "nsReadableUtils.h"
#include "nsSOAPHeaderBlock.h"
#include "nsSOAPUtils.h"
#include "nsIServiceManager.h"
#include "nsISOAPAttachments.h"
nsSOAPHeaderBlock::nsSOAPHeaderBlock()
{
NS_INIT_ISUPPORTS();
}
nsSOAPHeaderBlock::~nsSOAPHeaderBlock()
{
}
NS_IMPL_ISUPPORTS3_CI(nsSOAPHeaderBlock,
nsISOAPHeaderBlock,
nsISecurityCheckedComponent,
nsIJSNativeInitializer)
/* attribute AString namespaceURI; */
NS_IMETHODIMP nsSOAPHeaderBlock::GetNamespaceURI(nsAWritableString & aNamespaceURI)
{
NS_ENSURE_ARG_POINTER(&aNamespaceURI);
if (mElement) {
return mElement->GetNamespaceURI(aNamespaceURI);
}
else {
aNamespaceURI.Assign(mNamespaceURI);
}
return NS_OK;
}
NS_IMETHODIMP nsSOAPHeaderBlock::SetNamespaceURI(const nsAReadableString & aNamespaceURI)
{
if (mElement) {
return NS_ERROR_FAILURE;
}
mNamespaceURI.Assign(aNamespaceURI);
return NS_OK;
}
/* attribute AString name; */
NS_IMETHODIMP nsSOAPHeaderBlock::GetName(nsAWritableString & aName)
{
NS_ENSURE_ARG_POINTER(&aName);
if (mElement) {
return mElement->GetLocalName(aName);
}
else {
aName.Assign(mName);
}
return NS_OK;
}
NS_IMETHODIMP nsSOAPHeaderBlock::SetName(const nsAReadableString & aName)
{
if (mElement) {
return NS_ERROR_FAILURE;
}
mName.Assign(aName);
return NS_OK;
}
/* attribute AString actorURI; */
NS_IMETHODIMP nsSOAPHeaderBlock::GetActorURI(nsAWritableString & aActorURI)
{
NS_ENSURE_ARG_POINTER(&aActorURI);
if (mElement) {
return mElement->GetAttributeNS(nsSOAPUtils::kSOAPEnvURI,nsSOAPUtils::kActorAttribute,aActorURI);
}
else {
aActorURI.Assign(mActorURI);
}
return NS_OK;
}
NS_IMETHODIMP nsSOAPHeaderBlock::SetActorURI(const nsAReadableString & aActorURI)
{
if (mElement) {
return NS_ERROR_FAILURE;
}
mActorURI.Assign(aActorURI);
return NS_OK;
}
/* attribute nsISOAPEncoding encoding; */
NS_IMETHODIMP nsSOAPHeaderBlock::GetEncoding(nsISOAPEncoding* * aEncoding)
{
NS_ENSURE_ARG_POINTER(aEncoding);
*aEncoding = mEncoding;
NS_IF_ADDREF(*aEncoding);
return NS_OK;
}
NS_IMETHODIMP nsSOAPHeaderBlock::SetEncoding(nsISOAPEncoding* aEncoding)
{
mEncoding = aEncoding;
if (mElement) {
mComputeValue = PR_TRUE;
mValue = nsnull;
mStatus = NS_OK;
}
return NS_OK;
}
/* attribute nsISchemaType schemaType; */
NS_IMETHODIMP nsSOAPHeaderBlock::GetSchemaType(nsISchemaType* * aSchemaType)
{
NS_ENSURE_ARG_POINTER(aSchemaType);
*aSchemaType = mSchemaType;
NS_IF_ADDREF(*aSchemaType);
return NS_OK;
}
NS_IMETHODIMP nsSOAPHeaderBlock::SetSchemaType(nsISchemaType* aSchemaType)
{
mSchemaType = aSchemaType;
if (mElement) {
mComputeValue = PR_TRUE;
mValue = nsnull;
mStatus = NS_OK;
}
return NS_OK;
}
/* attribute nsISOAPAttachments attachments; */
NS_IMETHODIMP nsSOAPHeaderBlock::GetAttachments(nsISOAPAttachments* * aAttachments)
{
NS_ENSURE_ARG_POINTER(aAttachments);
*aAttachments = mAttachments;
NS_IF_ADDREF(*aAttachments);
return NS_OK;
}
NS_IMETHODIMP nsSOAPHeaderBlock::SetAttachments(nsISOAPAttachments* aAttachments)
{
mAttachments = aAttachments;
if (mElement) {
mComputeValue = PR_TRUE;
mValue = nsnull;
mStatus = NS_OK;
}
return NS_OK;
}
/* attribute nsIDOMElement element; */
NS_IMETHODIMP nsSOAPHeaderBlock::GetElement(nsIDOMElement* * aElement)
{
NS_ENSURE_ARG_POINTER(aElement);
*aElement = mElement;
NS_IF_ADDREF(*aElement);
return NS_OK;
}
NS_IMETHODIMP nsSOAPHeaderBlock::SetElement(nsIDOMElement* aElement)
{
mElement = aElement;
mNamespaceURI.SetLength(0);
mName.SetLength(0);
mActorURI.SetLength(0);
mComputeValue = PR_TRUE;
mValue = nsnull;
mStatus = NS_OK;
return NS_OK;
}
/* attribute nsIVariant value; */
NS_IMETHODIMP nsSOAPHeaderBlock::GetValue(nsIVariant* * aValue)
{
NS_ENSURE_ARG_POINTER(aValue);
if (mElement // Check for auto-computation
&& mComputeValue
&& mEncoding)
{
mComputeValue = PR_FALSE;
mStatus = mEncoding->Decode(mElement, mSchemaType, mAttachments, getter_AddRefs(mValue));
}
*aValue = mValue;
NS_IF_ADDREF(*aValue);
return mElement ? mStatus : NS_OK;
}
NS_IMETHODIMP nsSOAPHeaderBlock::SetValue(nsIVariant* aValue)
{
mValue = aValue;
mComputeValue = PR_FALSE;
mElement = nsnull;
return NS_OK;
}
NS_IMETHODIMP
nsSOAPHeaderBlock::Initialize(JSContext *cx, JSObject *obj,
PRUint32 argc, jsval *argv)
{
// Get the arguments.
nsCOMPtr<nsIVariant> value;
nsAutoString name;
nsAutoString namespaceURI;
nsAutoString actorURI;
nsCOMPtr<nsISupports> schemaType;
nsCOMPtr<nsISupports> encoding;
if (!JS_ConvertArguments(cx, argc, argv, "/%iv %is %is %is %ip %ip",
getter_AddRefs(value),
NS_STATIC_CAST(nsAString*, &name),
NS_STATIC_CAST(nsAString*, &namespaceURI),
NS_STATIC_CAST(nsAString*, &actorURI),
getter_AddRefs(schemaType),
getter_AddRefs(encoding))) return NS_ERROR_ILLEGAL_VALUE;
nsresult rc = SetValue(value);
if (NS_FAILED(rc)) return rc;
rc = SetName(name);
if (NS_FAILED(rc)) return rc;
rc = SetNamespaceURI(namespaceURI);
if (NS_FAILED(rc)) return rc;
rc = SetActorURI(actorURI);
if (NS_FAILED(rc)) return rc;
if (schemaType) {
nsCOMPtr<nsISchemaType> v = do_QueryInterface(schemaType, &rc);
if (NS_FAILED(rc)) return rc;
rc = SetSchemaType(v);
if (NS_FAILED(rc)) return rc;
}
if (encoding) {
nsCOMPtr<nsISOAPEncoding> v = do_QueryInterface(encoding, &rc);
if (NS_FAILED(rc)) return rc;
rc = SetEncoding(v);
if (NS_FAILED(rc)) return rc;
}
return NS_OK;
}
static const char* kAllAccess = "AllAccess";
/* string canCreateWrapper (in nsIIDPtr iid); */
NS_IMETHODIMP
nsSOAPHeaderBlock::CanCreateWrapper(const nsIID * iid, char **_retval)
{
if (iid->Equals(NS_GET_IID(nsISOAPHeaderBlock))) {
*_retval = nsCRT::strdup(kAllAccess);
}
return NS_OK;
}
/* string canCallMethod (in nsIIDPtr iid, in wstring methodName); */
NS_IMETHODIMP
nsSOAPHeaderBlock::CanCallMethod(const nsIID * iid, const PRUnichar *methodName, char **_retval)
{
if (iid->Equals(NS_GET_IID(nsISOAPHeaderBlock))) {
*_retval = nsCRT::strdup(kAllAccess);
}
return NS_OK;
}
/* string canGetProperty (in nsIIDPtr iid, in wstring propertyName); */
NS_IMETHODIMP
nsSOAPHeaderBlock::CanGetProperty(const nsIID * iid, const PRUnichar *propertyName, char **_retval)
{
if (iid->Equals(NS_GET_IID(nsISOAPHeaderBlock))) {
*_retval = nsCRT::strdup(kAllAccess);
}
return NS_OK;
}
/* string canSetProperty (in nsIIDPtr iid, in wstring propertyName); */
NS_IMETHODIMP
nsSOAPHeaderBlock::CanSetProperty(const nsIID * iid, const PRUnichar *propertyName, char **_retval)
{
if (iid->Equals(NS_GET_IID(nsISOAPHeaderBlock))) {
*_retval = nsCRT::strdup(kAllAccess);
}
return NS_OK;
}

View File

@@ -0,0 +1,70 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Netscape 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/NPL/
*
* Software distributed under the License is distributed on an "AS
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
* implied. See the License for the specific language governing
* rights and limitations under the License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All
* Rights Reserved.
*
* Contributor(s):
*/
#ifndef nsSOAPHeaderBlock_h__
#define nsSOAPHeaderBlock_h__
#include "nsString.h"
#include "nsIVariant.h"
#include "nsISOAPHeaderBlock.h"
#include "nsISecurityCheckedComponent.h"
#include "nsIJSNativeInitializer.h"
#include "nsISOAPEncoding.h"
#include "nsISchema.h"
#include "nsIDOMElement.h"
#include "nsISOAPAttachments.h"
#include "nsCOMPtr.h"
class nsSOAPHeaderBlock : public nsISOAPHeaderBlock,
public nsISecurityCheckedComponent,
public nsIJSNativeInitializer
{
public:
nsSOAPHeaderBlock();
virtual ~nsSOAPHeaderBlock();
NS_DECL_ISUPPORTS
// nsISOAPHeaderBlock
NS_DECL_NSISOAPHEADERBLOCK
// nsISecurityCheckedComponent
NS_DECL_NSISECURITYCHECKEDCOMPONENT
// nsIJSNativeInitializer
NS_IMETHOD Initialize(JSContext *cx, JSObject *obj,
PRUint32 argc, jsval *argv);
protected:
nsString mNamespaceURI;
nsString mName;
nsString mActorURI;
nsCOMPtr<nsISOAPEncoding> mEncoding;
nsCOMPtr<nsISchemaType> mSchemaType;
nsCOMPtr<nsISOAPAttachments> mAttachments;
nsCOMPtr<nsIDOMElement> mElement;
nsCOMPtr<nsIVariant> mValue;
nsresult mStatus;
PRBool mComputeValue;
};
#endif

View File

@@ -0,0 +1,475 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Netscape 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/NPL/
*
* Software distributed under the License is distributed on an "AS
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
* implied. See the License for the specific language governing
* rights and limitations under the License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All
* Rights Reserved.
*
* Contributor(s):
*/
#include "nsIServiceManager.h"
#include "nsMemory.h"
#include "nsIComponentManager.h"
#include "nsSOAPUtils.h"
#include "nsSOAPMessage.h"
#include "nsSOAPParameter.h"
#include "nsSOAPHeaderBlock.h"
#include "nsSOAPEncoding.h"
#include "nsIDOMDocument.h"
#include "nsIDOMParser.h"
#include "nsIDOMElement.h"
#include "nsIDOMNamedNodeMap.h"
static NS_DEFINE_CID(kDOMParserCID, NS_DOMPARSER_CID);
/////////////////////////////////////////////
//
//
/////////////////////////////////////////////
nsSOAPMessage::nsSOAPMessage()
{
NS_INIT_ISUPPORTS();
}
nsSOAPMessage::~nsSOAPMessage()
{
}
NS_IMPL_ISUPPORTS2(nsSOAPMessage,
nsISOAPMessage,
nsISecurityCheckedComponent)
/* attribute nsIDOMDocument message; */
NS_IMETHODIMP nsSOAPMessage::GetMessage(nsIDOMDocument * *aMessage)
{
NS_ENSURE_ARG_POINTER(aMessage);
*aMessage = mMessage;
NS_IF_ADDREF(*aMessage);
return NS_OK;
}
NS_IMETHODIMP nsSOAPMessage::SetMessage(nsIDOMDocument * aMessage)
{
mMessage = aMessage;
return NS_OK;
}
/* readonly attribute nsIDOMElement envelope; */
NS_IMETHODIMP nsSOAPMessage::GetEnvelope(nsIDOMElement * *aEnvelope)
{
NS_ENSURE_ARG_POINTER(aEnvelope);
if (mMessage) {
nsCOMPtr<nsIDOMElement> root;
mMessage->GetDocumentElement(getter_AddRefs(root));
if (root) {
nsAutoString name, namespaceURI;
root->GetLocalName(name);
root->GetNamespaceURI(namespaceURI);
if (name.Equals(nsSOAPUtils::kEnvelopeTagName)
&& namespaceURI.Equals(nsSOAPUtils::kSOAPEnvURI))
{
*aEnvelope = root;
NS_ADDREF(*aEnvelope);
return NS_OK;
}
}
}
*aEnvelope = nsnull;
return NS_OK;
}
/* readonly attribute nsIDOMElement header; */
NS_IMETHODIMP nsSOAPMessage::GetHeader(nsIDOMElement * *aHeader)
{
NS_ENSURE_ARG_POINTER(aHeader);
nsCOMPtr<nsIDOMElement> env;
GetEnvelope(getter_AddRefs(env));
if (env) {
nsSOAPUtils::GetSpecificChildElement(env,
nsSOAPUtils::kSOAPEnvURI, nsSOAPUtils::kHeaderTagName,
aHeader);
}
else {
*aHeader = nsnull;
}
return NS_OK;
}
/* readonly attribute nsIDOMElement body; */
NS_IMETHODIMP nsSOAPMessage::GetBody(nsIDOMElement * *aBody)
{
NS_ENSURE_ARG_POINTER(aBody);
nsCOMPtr<nsIDOMElement> env;
GetEnvelope(getter_AddRefs(env));
if (env) {
nsSOAPUtils::GetSpecificChildElement(env,
nsSOAPUtils::kSOAPEnvURI, nsSOAPUtils::kBodyTagName,
aBody);
}
else {
*aBody = nsnull;
}
return NS_OK;
}
/* attribute DOMString actionURI; */
NS_IMETHODIMP nsSOAPMessage::GetActionURI(nsAWritableString & aActionURI)
{
NS_ENSURE_ARG_POINTER(&aActionURI);
aActionURI.Assign(mActionURI);
return NS_OK;
}
NS_IMETHODIMP nsSOAPMessage::SetActionURI(const nsAReadableString & aActionURI)
{
mActionURI.Assign(aActionURI);
return NS_OK;
}
/* readonly attribute AString methodName; */
NS_IMETHODIMP nsSOAPMessage::GetMethodName(nsAString & aMethodName)
{
NS_ENSURE_ARG_POINTER(&aMethodName);
nsCOMPtr<nsIDOMElement> body;
GetBody(getter_AddRefs(body));
if (body) {
nsCOMPtr<nsIDOMElement> method;
nsSOAPUtils::GetFirstChildElement(body, getter_AddRefs(method));
if (method) {
body->GetLocalName(aMethodName);
return NS_OK;
}
}
aMethodName.SetLength(0);
return NS_OK;
}
/* readonly attribute AString targetObjectURI; */
NS_IMETHODIMP nsSOAPMessage::GetTargetObjectURI(nsAString & aTargetObjectURI)
{
NS_ENSURE_ARG_POINTER(&aTargetObjectURI);
nsCOMPtr<nsIDOMElement> body;
GetBody(getter_AddRefs(body));
if (body) {
nsCOMPtr<nsIDOMElement> method;
nsSOAPUtils::GetFirstChildElement(body, getter_AddRefs(method));
if (method) {
body->GetNamespaceURI(aTargetObjectURI);
return NS_OK;
}
}
aTargetObjectURI.SetLength(0);
return NS_OK;
}
NS_NAMED_LITERAL_STRING(kEmptySOAPDocStr, "<SOAP-ENV:Envelope xmlns:SOAP-ENV=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:SOAP-ENC=\"http://schemas.xmlsoap.org/soap/encoding/\" xmlns:xsi=\"http://www.w3.org/1999/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/1999/XMLSchema\"><SOAP-ENV:Header></SOAP-ENV:Header><SOAP-ENV:Body></SOAP-ENV:Body></SOAP-ENV:Envelope>");
/* void encode (in AString aMethodName, in AString aTargetObjectURI, in PRUint32 aHeaderBlockCount, [array, size_is (aHeaderBlockCount)] in nsISOAPHeaderBlock aHeaderBlocks, in PRUint32 aParameterCount, [array, size_is (aParameterCount)] in nsISOAPParameter aParameters); */
NS_IMETHODIMP nsSOAPMessage::Encode(const nsAString & aMethodName, const nsAString & aTargetObjectURI, PRUint32 aHeaderBlockCount, nsISOAPHeaderBlock **aHeaderBlocks, PRUint32 aParameterCount, nsISOAPParameter **aParameters)
{
// Construct the message skeleton
nsresult rv;
nsCOMPtr<nsIDOMNode> ignored;
nsCOMPtr<nsIDOMParser> parser = do_CreateInstance(kDOMParserCID, &rv);
if (NS_FAILED(rv)) return rv;
nsAutoString docstr;
rv = parser->ParseFromString(kEmptySOAPDocStr.get(), "text/xml",
getter_AddRefs(mMessage));
if (NS_FAILED(rv)) return rv;
// Declare the default encoding if one exists
if (mEncoding) {
nsCOMPtr<nsIDOMElement> envelope;
rv = GetEnvelope(getter_AddRefs(envelope));
if (NS_FAILED(rv)) return rv;
if (envelope) {
nsAutoString enc;
mEncoding->GetStyleURI(enc);
envelope->SetAttributeNS(nsSOAPUtils::kSOAPEncodingURI, nsSOAPUtils::kEncodingStyleAttribute, enc);
}
}
// Encode and add headers, if any were specified
if (aHeaderBlockCount) {
nsCOMPtr<nsIDOMElement> parent;
rv = GetHeader(getter_AddRefs(parent));
if (NS_FAILED(rv)) return rv;
nsCOMPtr<nsISupports> next;
nsCOMPtr<nsISOAPHeaderBlock> header;
nsCOMPtr<nsIDOMElement> element;
nsCOMPtr<nsISOAPEncoding> encoding;
nsCOMPtr<nsISchemaType> schemaType;
nsCOMPtr<nsIVariant> value;
nsAutoString name;
nsAutoString namespaceURI;
nsAutoString actorURI;
for (PRUint32 i = 0; i < aHeaderBlockCount; i++) {
header = aHeaderBlocks[i];
if (!header) return NS_ERROR_FAILURE;
rv = header->GetElement(getter_AddRefs(element));
if (element) {
nsCOMPtr<nsIDOMNode> node1 = (nsIDOMElement*)element;
nsCOMPtr<nsIDOMNode> node2;
rv = mMessage->ImportNode(node1, PR_TRUE, getter_AddRefs(node1));
if (NS_FAILED(rv)) return rv;
rv = parent->AppendChild(node2, getter_AddRefs(node1));
if (NS_FAILED(rv)) return rv;
element = do_QueryInterface(node1);
}
else {
rv = header->GetNamespaceURI(namespaceURI);
if (NS_FAILED(rv)) return rv;
rv = header->GetName(name);
if (NS_FAILED(rv)) return rv;
rv = header->GetActorURI(actorURI);
if (NS_FAILED(rv)) return rv;
rv = header->GetEncoding(getter_AddRefs(encoding));
if (NS_FAILED(rv)) return rv;
if (!encoding) {
encoding = mEncoding;
}
rv = header->GetSchemaType(getter_AddRefs(schemaType));
if (NS_FAILED(rv)) return rv;
rv = header->GetValue(getter_AddRefs(value));
if (NS_FAILED(rv)) return rv;
rv = encoding->Encode(value, namespaceURI, name,
schemaType, nsnull, parent, getter_AddRefs(element));
if (NS_FAILED(rv)) return rv;
if (!actorURI.IsEmpty()) {
element->SetAttributeNS(nsSOAPUtils::kSOAPEnvPrefix, nsSOAPUtils::kActorAttribute, actorURI);
}
if (mEncoding != encoding) {
nsAutoString enc;
encoding->GetStyleURI(enc);
element->SetAttributeNS(nsSOAPUtils::kSOAPEncodingURI, nsSOAPUtils::kEncodingStyleAttribute, enc);
}
}
}
}
nsCOMPtr<nsIDOMElement> body;
rv = GetBody(getter_AddRefs(body));
if (NS_FAILED(rv)) return rv;
// Only produce a call element if mMethodName was non-empty
if (!aMethodName.IsEmpty()) {
nsCOMPtr<nsIDOMElement> call;
rv = mMessage->CreateElementNS(aTargetObjectURI, aMethodName, getter_AddRefs(call));
if (NS_FAILED(rv)) return rv;
nsCOMPtr<nsIDOMNode> ignored;
rv = body->AppendChild(call, getter_AddRefs(ignored));
if (NS_FAILED(rv)) return rv;
body = call;
nsAutoString prefix;
rv = nsSOAPUtils::MakeNamespacePrefixFixed(body, aTargetObjectURI, prefix);
if (NS_FAILED(rv)) return rv;
if (!prefix.IsEmpty()) {
rv = body->SetPrefix(prefix);
if (NS_FAILED(rv)) return rv;
}
}
// Encode and add all of the parameters into the body
nsCOMPtr<nsISupports> next;
nsCOMPtr<nsISOAPParameter> param;
nsCOMPtr<nsIDOMElement> element;
nsCOMPtr<nsISOAPEncoding> encoding;
nsCOMPtr<nsISchemaType> schemaType;
nsCOMPtr<nsIVariant> value;
nsAutoString name;
nsAutoString namespaceURI;
for (PRUint32 i = 0; i < aParameterCount; i++) {
param = aParameters[i];
if (!param) return NS_ERROR_FAILURE;
rv = param->GetElement(getter_AddRefs(element));
if (element) {
nsCOMPtr<nsIDOMNode> node1 = (nsIDOMElement*)element;
nsCOMPtr<nsIDOMNode> node2;
rv = mMessage->ImportNode(node1, PR_TRUE, getter_AddRefs(node1));
if (NS_FAILED(rv)) return rv;
rv = body->AppendChild(node2, getter_AddRefs(node1));
if (NS_FAILED(rv)) return rv;
element = do_QueryInterface(node1);
}
else {
rv = param->GetNamespaceURI(namespaceURI);
if (NS_FAILED(rv)) return rv;
rv = param->GetName(name);
if (NS_FAILED(rv)) return rv;
rv = param->GetEncoding(getter_AddRefs(encoding));
if (NS_FAILED(rv)) return rv;
if (!encoding) {
encoding = mEncoding;
}
rv = param->GetSchemaType(getter_AddRefs(schemaType));
if (NS_FAILED(rv)) return rv;
rv = param->GetValue(getter_AddRefs(value));
if (NS_FAILED(rv)) return rv;
rv = encoding->Encode(value, namespaceURI, name,
schemaType, nsnull, body, getter_AddRefs(element));
if (NS_FAILED(rv)) return rv;
if (mEncoding != encoding) {
nsAutoString enc;
encoding->GetStyleURI(enc);
element->SetAttributeNS(nsSOAPUtils::kSOAPEncodingURI, nsSOAPUtils::kEncodingStyleAttribute, enc);
}
}
}
return NS_OK;
}
static NS_DEFINE_CID(kMemoryCID, NS_MEMORY_CID);
/* void getHeaderBlocks (out PRUint32 aCount, [array, size_is (aCount), retval] out nsISOAPHeaderBlock aHeaderBlocks); */
NS_IMETHODIMP nsSOAPMessage::GetHeaderBlocks(PRUint32 *aCount, nsISOAPHeaderBlock ***aHeaderBlocks)
{
nsCOMPtr<nsIMemory> memory = do_GetService(kMemoryCID);
*aCount = 0;
*aHeaderBlocks = nsnull;
int count = 0;
int length = 0;
nsCOMPtr<nsIDOMElement> element;
nsresult rv = GetHeader(getter_AddRefs(element));
if (NS_FAILED(rv)) return rv;
nsCOMPtr<nsIDOMElement> next;
nsCOMPtr<nsISOAPHeaderBlock> header;
nsSOAPUtils::GetFirstChildElement(element, getter_AddRefs(next));
while (next) {
if (length == count) {
length = length ? 2 * length : 10;
*aHeaderBlocks = (nsISOAPHeaderBlock* *)memory->Realloc(*aHeaderBlocks, length * sizeof(**aHeaderBlocks));
}
element = next;
header = new nsSOAPHeaderBlock();
if (NS_FAILED(rv)) return rv;
// XXX can't addref a COMPTr
//NS_ADDREF(header);
(*aHeaderBlocks)[(*aCount)++] = header;
rv = header->SetElement(element);
if (NS_FAILED(rv)) return rv;
nsSOAPUtils::GetNextSiblingElement(element, getter_AddRefs(next));
}
if (*aCount) {
*aHeaderBlocks = (nsISOAPHeaderBlock* *)memory->Realloc(*aHeaderBlocks, (*aCount) * sizeof(**aHeaderBlocks));
}
return NS_OK;
}
/* void getParameters (in boolean aDocumentStyle, out PRUint32 aCount, [array, size_is (aCount), retval] out nsISOAPParameter aParameters); */
NS_IMETHODIMP nsSOAPMessage::GetParameters(PRBool aDocumentStyle, PRUint32 *aCount, nsISOAPParameter ***aParameters)
{
nsCOMPtr<nsIMemory> memory = do_GetService(kMemoryCID);
*aCount = 0;
*aParameters = nsnull;
int count = 0;
int length = 0;
nsCOMPtr<nsIDOMElement> element;
nsresult rv = GetHeader(getter_AddRefs(element));
if (NS_FAILED(rv)) return rv;
nsCOMPtr<nsIDOMElement> next;
nsCOMPtr<nsISOAPParameter> param;
nsSOAPUtils::GetFirstChildElement(element, getter_AddRefs(next));
while (next) {
if (length == count) {
length = length ? 2 * length : 10;
*aParameters = (nsISOAPParameter* *)memory->Realloc(*aParameters, length * sizeof(**aParameters));
}
element = next;
param = new nsSOAPParameter();
if (NS_FAILED(rv)) return rv;
// XXX can't addref a COMPTr
//NS_ADDREF(param);
(*aParameters)[(*aCount)++] = param;
rv = param->SetElement(element);
if (NS_FAILED(rv)) return rv;
nsSOAPUtils::GetNextSiblingElement(element, getter_AddRefs(next));
}
if (*aCount) {
*aParameters = (nsISOAPParameter* *)memory->Realloc(*aParameters, (*aCount) * sizeof(**aParameters));
}
return NS_OK;
}
/* attribute nsISOAPEncoding encoding; */
NS_IMETHODIMP nsSOAPMessage::GetEncoding(nsISOAPEncoding* * aEncoding)
{
NS_ENSURE_ARG_POINTER(aEncoding);
if (!mEncoding) {
mEncoding = new nsSOAPEncoding();
if (!mEncoding)
return NS_ERROR_OUT_OF_MEMORY;
}
*aEncoding = mEncoding;
NS_IF_ADDREF(*aEncoding);
return NS_OK;
}
NS_IMETHODIMP nsSOAPMessage::SetEncoding(nsISOAPEncoding* aEncoding)
{
mEncoding = aEncoding;
return NS_OK;
}
static const char*kAllAccess = "AllAccess";
/* string canCreateWrapper (in nsIIDPtr iid); */
NS_IMETHODIMP
nsSOAPMessage::CanCreateWrapper(const nsIID * iid, char**_retval)
{
if (iid->Equals(NS_GET_IID(nsISOAPMessage))) {
*_retval = nsCRT::strdup(kAllAccess);
}
return NS_OK;
}
/* string canCallMethod (in nsIIDPtr iid, in wstring methodName); */
NS_IMETHODIMP
nsSOAPMessage::CanCallMethod(const nsIID * iid, const PRUnichar*methodName, char**_retval)
{
if (iid->Equals(NS_GET_IID(nsISOAPMessage))) {
*_retval = nsCRT::strdup(kAllAccess);
}
return NS_OK;
}
/* string canGetProperty (in nsIIDPtr iid, in wstring propertyName); */
NS_IMETHODIMP
nsSOAPMessage::CanGetProperty(const nsIID * iid, const PRUnichar*propertyName, char**_retval)
{
if (iid->Equals(NS_GET_IID(nsISOAPMessage))) {
*_retval = nsCRT::strdup(kAllAccess);
}
return NS_OK;
}
/* string canSetProperty (in nsIIDPtr iid, in wstring propertyName); */
NS_IMETHODIMP
nsSOAPMessage::CanSetProperty(const nsIID * iid, const PRUnichar*propertyName, char**_retval)
{
if (iid->Equals(NS_GET_IID(nsISOAPMessage))) {
*_retval = nsCRT::strdup(kAllAccess);
}
return NS_OK;
}

View File

@@ -0,0 +1,58 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Netscape 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/NPL/
*
* Software distributed under the License is distributed on an "AS
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
* implied. See the License for the specific language governing
* rights and limitations under the License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All
* Rights Reserved.
*
* Contributor(s):
*/
#ifndef nsSOAPMessage_h__
#define nsSOAPMessage_h__
#include "nsString.h"
#include "nsISOAPEncoding.h"
#include "nsISOAPMessage.h"
#include "nsISecurityCheckedComponent.h"
#include "nsIDOMElement.h"
#include "nsIDOMDocument.h"
#include "nsISupportsArray.h"
#include "nsCOMPtr.h"
#include "nsIVariant.h"
class nsSOAPMessage : public nsISOAPMessage,
public nsISecurityCheckedComponent
{
public:
nsSOAPMessage();
virtual ~nsSOAPMessage();
NS_DECL_ISUPPORTS
// nsISOAPMessage
NS_DECL_NSISOAPMESSAGE
// nsISecurityCheckedComponent
NS_DECL_NSISECURITYCHECKEDCOMPONENT
protected:
nsCOMPtr<nsIDOMDocument> mMessage;
nsCOMPtr<nsISOAPEncoding> mEncoding;
nsString mActionURI;
};
#endif

View File

@@ -0,0 +1,271 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Netscape 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/NPL/
*
* Software distributed under the License is distributed on an "AS
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
* implied. See the License for the specific language governing
* rights and limitations under the License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All
* Rights Reserved.
*
* Contributor(s):
*/
#include "nsString.h"
#include "nsReadableUtils.h"
#include "nsSOAPParameter.h"
#include "nsSOAPUtils.h"
#include "nsIServiceManager.h"
#include "nsISOAPAttachments.h"
nsSOAPParameter::nsSOAPParameter()
{
NS_INIT_ISUPPORTS();
}
nsSOAPParameter::~nsSOAPParameter()
{
}
NS_IMPL_ISUPPORTS3_CI(nsSOAPParameter,
nsISOAPParameter,
nsISecurityCheckedComponent,
nsIJSNativeInitializer)
/* attribute AString namespaceURI; */
NS_IMETHODIMP nsSOAPParameter::GetNamespaceURI(nsAWritableString & aNamespaceURI)
{
NS_ENSURE_ARG_POINTER(&aNamespaceURI);
if (mElement) {
return mElement->GetNamespaceURI(aNamespaceURI);
}
else {
aNamespaceURI.Assign(mNamespaceURI);
}
return NS_OK;
}
NS_IMETHODIMP nsSOAPParameter::SetNamespaceURI(const nsAReadableString & aNamespaceURI)
{
if (mElement) {
return NS_ERROR_FAILURE;
}
mNamespaceURI.Assign(aNamespaceURI);
return NS_OK;
}
/* attribute AString name; */
NS_IMETHODIMP nsSOAPParameter::GetName(nsAWritableString & aName)
{
NS_ENSURE_ARG_POINTER(&aName);
if (mElement) {
return mElement->GetLocalName(aName);
}
else {
aName.Assign(mName);
}
return NS_OK;
}
NS_IMETHODIMP nsSOAPParameter::SetName(const nsAReadableString & aName)
{
if (mElement) {
return NS_ERROR_FAILURE;
}
mName.Assign(aName);
return NS_OK;
}
/* attribute nsISOAPEncoding encoding; */
NS_IMETHODIMP nsSOAPParameter::GetEncoding(nsISOAPEncoding* * aEncoding)
{
NS_ENSURE_ARG_POINTER(aEncoding);
*aEncoding = mEncoding;
NS_IF_ADDREF(*aEncoding);
return NS_OK;
}
NS_IMETHODIMP nsSOAPParameter::SetEncoding(nsISOAPEncoding* aEncoding)
{
mEncoding = aEncoding;
if (mElement) {
mComputeValue = PR_TRUE;
mValue = nsnull;
mStatus = NS_OK;
}
return NS_OK;
}
/* attribute nsISchemaType schemaType; */
NS_IMETHODIMP nsSOAPParameter::GetSchemaType(nsISchemaType* * aSchemaType)
{
NS_ENSURE_ARG_POINTER(aSchemaType);
*aSchemaType = mSchemaType;
NS_IF_ADDREF(*aSchemaType);
return NS_OK;
}
NS_IMETHODIMP nsSOAPParameter::SetSchemaType(nsISchemaType* aSchemaType)
{
mSchemaType = aSchemaType;
if (mElement) {
mComputeValue = PR_TRUE;
mValue = nsnull;
mStatus = NS_OK;
}
return NS_OK;
}
/* attribute nsISOAPAttachments attachments; */
NS_IMETHODIMP nsSOAPParameter::GetAttachments(nsISOAPAttachments* * aAttachments)
{
NS_ENSURE_ARG_POINTER(aAttachments);
*aAttachments = mAttachments;
NS_IF_ADDREF(*aAttachments);
return NS_OK;
}
NS_IMETHODIMP nsSOAPParameter::SetAttachments(nsISOAPAttachments* aAttachments)
{
mAttachments = aAttachments;
if (mElement) {
mComputeValue = PR_TRUE;
mValue = nsnull;
mStatus = NS_OK;
}
return NS_OK;
}
/* attribute nsIDOMElement element; */
NS_IMETHODIMP nsSOAPParameter::GetElement(nsIDOMElement* * aElement)
{
NS_ENSURE_ARG_POINTER(aElement);
*aElement = mElement;
NS_IF_ADDREF(*aElement);
return NS_OK;
}
NS_IMETHODIMP nsSOAPParameter::SetElement(nsIDOMElement* aElement)
{
mElement = aElement;
mNamespaceURI.SetLength(0);
mName.SetLength(0);
mComputeValue = PR_TRUE;
mValue = nsnull;
mStatus = NS_OK;
return NS_OK;
}
/* attribute nsIVariant value; */
NS_IMETHODIMP nsSOAPParameter::GetValue(nsIVariant* * aValue)
{
NS_ENSURE_ARG_POINTER(aValue);
if (mElement // Check for auto-computation
&& mComputeValue
&& mEncoding)
{
mComputeValue = PR_FALSE;
mStatus = mEncoding->Decode(mElement, mSchemaType, mAttachments, getter_AddRefs(mValue));
}
*aValue = mValue;
NS_IF_ADDREF(*aValue);
return mElement ? mStatus : NS_OK;
}
NS_IMETHODIMP nsSOAPParameter::SetValue(nsIVariant* aValue)
{
mValue = aValue;
mComputeValue = PR_FALSE;
mElement = nsnull;
return NS_OK;
}
NS_IMETHODIMP
nsSOAPParameter::Initialize(JSContext *cx, JSObject *obj,
PRUint32 argc, jsval *argv)
{
// Get the arguments.
nsCOMPtr<nsIVariant> value;
nsAutoString name;
nsAutoString namespaceURI;
nsCOMPtr<nsISupports> schemaType;
nsCOMPtr<nsISupports> encoding;
if (!JS_ConvertArguments(cx, argc, argv, "/%iv %is %is %ip %ip",
getter_AddRefs(value),
NS_STATIC_CAST(nsAString*, &name),
NS_STATIC_CAST(nsAString*, &namespaceURI),
getter_AddRefs(schemaType),
getter_AddRefs(encoding))) return NS_ERROR_ILLEGAL_VALUE;
nsresult rc = SetValue(value);
if (NS_FAILED(rc)) return rc;
rc = SetName(name);
if (NS_FAILED(rc)) return rc;
rc = SetNamespaceURI(namespaceURI);
if (NS_FAILED(rc)) return rc;
if (schemaType) {
nsCOMPtr<nsISchemaType> v = do_QueryInterface(schemaType, &rc);
if (NS_FAILED(rc)) return rc;
rc = SetSchemaType(v);
if (NS_FAILED(rc)) return rc;
}
if (encoding) {
nsCOMPtr<nsISOAPEncoding> v = do_QueryInterface(encoding, &rc);
if (NS_FAILED(rc)) return rc;
rc = SetEncoding(v);
if (NS_FAILED(rc)) return rc;
}
return NS_OK;
}
static const char* kAllAccess = "AllAccess";
/* string canCreateWrapper (in nsIIDPtr iid); */
NS_IMETHODIMP
nsSOAPParameter::CanCreateWrapper(const nsIID * iid, char **_retval)
{
if (iid->Equals(NS_GET_IID(nsISOAPParameter))) {
*_retval = nsCRT::strdup(kAllAccess);
}
return NS_OK;
}
/* string canCallMethod (in nsIIDPtr iid, in wstring methodName); */
NS_IMETHODIMP
nsSOAPParameter::CanCallMethod(const nsIID * iid, const PRUnichar *methodName, char **_retval)
{
if (iid->Equals(NS_GET_IID(nsISOAPParameter))) {
*_retval = nsCRT::strdup(kAllAccess);
}
return NS_OK;
}
/* string canGetProperty (in nsIIDPtr iid, in wstring propertyName); */
NS_IMETHODIMP
nsSOAPParameter::CanGetProperty(const nsIID * iid, const PRUnichar *propertyName, char **_retval)
{
if (iid->Equals(NS_GET_IID(nsISOAPParameter))) {
*_retval = nsCRT::strdup(kAllAccess);
}
return NS_OK;
}
/* string canSetProperty (in nsIIDPtr iid, in wstring propertyName); */
NS_IMETHODIMP
nsSOAPParameter::CanSetProperty(const nsIID * iid, const PRUnichar *propertyName, char **_retval)
{
if (iid->Equals(NS_GET_IID(nsISOAPParameter))) {
*_retval = nsCRT::strdup(kAllAccess);
}
return NS_OK;
}

View File

@@ -0,0 +1,69 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Netscape 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/NPL/
*
* Software distributed under the License is distributed on an "AS
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
* implied. See the License for the specific language governing
* rights and limitations under the License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All
* Rights Reserved.
*
* Contributor(s):
*/
#ifndef nsSOAPParameter_h__
#define nsSOAPParameter_h__
#include "nsString.h"
#include "nsIVariant.h"
#include "nsISOAPParameter.h"
#include "nsISecurityCheckedComponent.h"
#include "nsIJSNativeInitializer.h"
#include "nsISOAPEncoding.h"
#include "nsISchema.h"
#include "nsIDOMElement.h"
#include "nsISOAPAttachments.h"
#include "nsCOMPtr.h"
class nsSOAPParameter : public nsISOAPParameter,
public nsISecurityCheckedComponent,
public nsIJSNativeInitializer
{
public:
nsSOAPParameter();
virtual ~nsSOAPParameter();
NS_DECL_ISUPPORTS
// nsISOAPParameter
NS_DECL_NSISOAPPARAMETER
// nsISecurityCheckedComponent
NS_DECL_NSISECURITYCHECKEDCOMPONENT
// nsIJSNativeInitializer
NS_IMETHOD Initialize(JSContext *cx, JSObject *obj,
PRUint32 argc, jsval *argv);
protected:
nsString mNamespaceURI;
nsString mName;
nsCOMPtr<nsISOAPEncoding> mEncoding;
nsCOMPtr<nsISchemaType> mSchemaType;
nsCOMPtr<nsISOAPAttachments> mAttachments;
nsCOMPtr<nsIDOMElement> mElement;
nsCOMPtr<nsIVariant> mValue;
nsresult mStatus;
PRBool mComputeValue;
};
#endif

View File

@@ -0,0 +1,122 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Netscape 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/NPL/
*
* Software distributed under the License is distributed on an "AS
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
* implied. See the License for the specific language governing
* rights and limitations under the License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All
* Rights Reserved.
*
* Contributor(s):
*/
#include "nsSOAPResponse.h"
#include "nsSOAPUtils.h"
#include "nsSOAPFault.h"
#include "nsISOAPParameter.h"
nsSOAPResponse::nsSOAPResponse()
{
}
nsSOAPResponse::~nsSOAPResponse()
{
/* destructor code */
}
NS_IMPL_ISUPPORTS_INHERITED1(nsSOAPResponse, nsSOAPMessage, nsISOAPResponse)
/* attribute nsISOAPCall respondingTo; */
NS_IMETHODIMP nsSOAPResponse::GetRespondingTo(nsISOAPCall * *aRespondingTo)
{
NS_ENSURE_ARG_POINTER(aRespondingTo);
*aRespondingTo = mRespondingTo;
NS_IF_ADDREF(*aRespondingTo);
return NS_OK;
}
NS_IMETHODIMP nsSOAPResponse::SetRespondingTo(nsISOAPCall * aRespondingTo)
{
mRespondingTo = aRespondingTo;
return NS_OK;
}
/* readonly attribute nsISOAPFault fault; */
NS_IMETHODIMP nsSOAPResponse::GetFault(nsISOAPFault * *aFault)
{
NS_ENSURE_ARG_POINTER(aFault);
nsCOMPtr<nsIDOMElement> body;
*aFault = nsnull;
GetBody(getter_AddRefs(body));
if (body) {
nsSOAPUtils::GetSpecificChildElement(body,
nsSOAPUtils::kSOAPEnvURI, nsSOAPUtils::kFaultTagName,
getter_AddRefs(body));
if (body) {
*aFault = new nsSOAPFault(body);
if (!*aFault)
return NS_ERROR_OUT_OF_MEMORY;
NS_ADDREF(*aFault);
}
}
else {
*aFault = nsnull;
}
return NS_OK;
}
static const char* kAllAccess = "AllAccess";
/* string canCreateWrapper (in nsIIDPtr iid); */
NS_IMETHODIMP
nsSOAPResponse::CanCreateWrapper(const nsIID * iid, char **_retval)
{
if (iid->Equals(NS_GET_IID(nsISOAPResponse))) {
*_retval = nsCRT::strdup(kAllAccess);
}
return NS_OK;
}
/* string canCallMethod (in nsIIDPtr iid, in wstring methodName); */
NS_IMETHODIMP
nsSOAPResponse::CanCallMethod(const nsIID * iid, const PRUnichar *methodName, char **_retval)
{
if (iid->Equals(NS_GET_IID(nsISOAPResponse))) {
*_retval = nsCRT::strdup(kAllAccess);
}
return NS_OK;
}
/* string canGetProperty (in nsIIDPtr iid, in wstring propertyName); */
NS_IMETHODIMP
nsSOAPResponse::CanGetProperty(const nsIID * iid, const PRUnichar *propertyName, char **_retval)
{
if (iid->Equals(NS_GET_IID(nsISOAPResponse))) {
*_retval = nsCRT::strdup(kAllAccess);
}
return NS_OK;
}
/* string canSetProperty (in nsIIDPtr iid, in wstring propertyName); */
NS_IMETHODIMP
nsSOAPResponse::CanSetProperty(const nsIID * iid, const PRUnichar *propertyName, char **_retval)
{
if (iid->Equals(NS_GET_IID(nsISOAPResponse))) {
*_retval = nsCRT::strdup(kAllAccess);
}
return NS_OK;
}

View File

@@ -0,0 +1,56 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Netscape 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/NPL/
*
* Software distributed under the License is distributed on an "AS
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
* implied. See the License for the specific language governing
* rights and limitations under the License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All
* Rights Reserved.
*
* Contributor(s):
*/
#ifndef nsSOAPResponse_h__
#define nsSOAPResponse_h__
#include "nsString.h"
#include "nsSOAPCall.h"
#include "nsISOAPResponse.h"
#include "nsISecurityCheckedComponent.h"
#include "nsIDOMDocument.h"
#include "nsIDOMElement.h"
#include "nsCOMPtr.h"
class nsSOAPResponse : public nsSOAPMessage,
public nsISOAPResponse
{
public:
NS_DECL_ISUPPORTS
// nsISOAPResponse
NS_FORWARD_NSISOAPMESSAGE(nsSOAPMessage::)
// nsISOAPResponse
NS_DECL_NSISOAPRESPONSE
// nsISecurityCheckedComponent
NS_DECL_NSISECURITYCHECKEDCOMPONENT
nsSOAPResponse();
virtual ~nsSOAPResponse();
protected:
nsCOMPtr<nsISOAPCall> mRespondingTo;
};
#endif

View File

@@ -0,0 +1,426 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Netscape 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/NPL/
*
* Software distributed under the License is distributed on an "AS
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
* implied. See the License for the specific language governing
* rights and limitations under the License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All
* Rights Reserved.
*
* Contributor(s):
*/
#include "nsSOAPUtils.h"
#include "nsIDOMText.h"
#include "nsIDOMNamedNodeMap.h"
#include "nsCOMPtr.h"
NS_NAMED_LITERAL_STRING(nsSOAPUtils::kSOAPEnvURI,"http://schemas.xmlsoap.org/soap/envelope/");
NS_NAMED_LITERAL_STRING(nsSOAPUtils::kSOAPEncodingURI,"http://schemas.xmlsoap.org/soap/encoding/");
NS_NAMED_LITERAL_STRING(nsSOAPUtils::kSOAPEnvPrefix,"SOAP-ENV");
NS_NAMED_LITERAL_STRING(nsSOAPUtils::kSOAPEncodingPrefix,"SOAP-ENC");
NS_NAMED_LITERAL_STRING(nsSOAPUtils::kXSIURI,"http://www.w3.org/1999/XMLSchema-instance");
NS_NAMED_LITERAL_STRING(nsSOAPUtils::kXSDURI,"http://www.w3.org/1999/XMLSchema");
NS_NAMED_LITERAL_STRING(nsSOAPUtils::kXSIPrefix,"xsi");
NS_NAMED_LITERAL_STRING(nsSOAPUtils::kXSITypeAttribute,"type");
NS_NAMED_LITERAL_STRING(nsSOAPUtils::kXSDPrefix,"xsd");
NS_NAMED_LITERAL_STRING(nsSOAPUtils::kEncodingStyleAttribute,"encodingStyle");
NS_NAMED_LITERAL_STRING(nsSOAPUtils::kActorAttribute,"actor");
NS_NAMED_LITERAL_STRING(nsSOAPUtils::kEnvelopeTagName,"Envelope");
NS_NAMED_LITERAL_STRING(nsSOAPUtils::kHeaderTagName,"Header");
NS_NAMED_LITERAL_STRING(nsSOAPUtils::kBodyTagName,"Body");
NS_NAMED_LITERAL_STRING(nsSOAPUtils::kFaultTagName,"Fault");
NS_NAMED_LITERAL_STRING(nsSOAPUtils::kFaultCodeTagName,"faultcode");
NS_NAMED_LITERAL_STRING(nsSOAPUtils::kFaultStringTagName,"faultstring");
NS_NAMED_LITERAL_STRING(nsSOAPUtils::kFaultActorTagName,"faultactor");
NS_NAMED_LITERAL_STRING(nsSOAPUtils::kFaultDetailTagName,"detail");
NS_NAMED_LITERAL_STRING(nsSOAPUtils::kEncodingSeparator,"#");
NS_NAMED_LITERAL_STRING(nsSOAPUtils::kQualifiedSeparator,":");
NS_NAMED_LITERAL_STRING(nsSOAPUtils::kXMLNamespaceNamespaceURI, "htp://www.w3.org/2000/xmlns/");
NS_NAMED_LITERAL_STRING(nsSOAPUtils::kXMLNamespaceURI, "htp://www.w3.org/XML/1998/namespace");
NS_NAMED_LITERAL_STRING(nsSOAPUtils::kXMLPrefix, "xml:");
NS_NAMED_LITERAL_STRING(nsSOAPUtils::kXMLNamespacePrefix, "xmlns:");
void
nsSOAPUtils::GetSpecificChildElement(
nsIDOMElement *aParent,
const nsAReadableString& aNamespace,
const nsAReadableString& aType,
nsIDOMElement * *aElement)
{
nsCOMPtr<nsIDOMElement> sibling;
*aElement = nsnull;
GetFirstChildElement(aParent, getter_AddRefs(sibling));
if (sibling)
{
GetSpecificSiblingElement(sibling,
aNamespace, aType, aElement);
}
}
void
nsSOAPUtils::GetSpecificSiblingElement(
nsIDOMElement *aSibling,
const nsAReadableString& aNamespace,
const nsAReadableString& aType,
nsIDOMElement * *aElement)
{
nsCOMPtr<nsIDOMElement> sibling;
*aElement = nsnull;
sibling = aSibling;
do {
nsAutoString name, namespaceURI;
sibling->GetLocalName(name);
sibling->GetNamespaceURI(namespaceURI);
if (name.Equals(aType)
&& namespaceURI.Equals(nsSOAPUtils::kSOAPEnvURI))
{
*aElement = sibling;
NS_ADDREF(*aElement);
return;
}
nsCOMPtr<nsIDOMElement> temp = sibling;
GetNextSiblingElement(temp, getter_AddRefs(sibling));
} while (sibling);
}
void
nsSOAPUtils::GetFirstChildElement(nsIDOMElement* aParent,
nsIDOMElement** aElement)
{
nsCOMPtr<nsIDOMNode> child;
*aElement = nsnull;
aParent->GetFirstChild(getter_AddRefs(child));
while (child) {
PRUint16 type;
child->GetNodeType(&type);
if (nsIDOMNode::ELEMENT_NODE == type) {
child->QueryInterface(NS_GET_IID(nsIDOMElement), (void**)aElement);
break;
}
nsCOMPtr<nsIDOMNode> temp = child;
GetNextSibling(temp, getter_AddRefs(child));
}
}
void
nsSOAPUtils::GetNextSiblingElement(nsIDOMElement* aStart,
nsIDOMElement** aElement)
{
nsCOMPtr<nsIDOMNode> sibling;
*aElement = nsnull;
GetNextSibling(aStart, getter_AddRefs(sibling));
while (sibling) {
PRUint16 type;
sibling->GetNodeType(&type);
if (nsIDOMNode::ELEMENT_NODE == type) {
sibling->QueryInterface(NS_GET_IID(nsIDOMElement), (void**)aElement);
break;
}
nsCOMPtr<nsIDOMNode> temp = sibling;
GetNextSibling(temp, getter_AddRefs(sibling));
}
}
nsresult
nsSOAPUtils::GetElementTextContent(nsIDOMElement* aElement,
nsAWritableString& aText)
{
nsCOMPtr<nsIDOMNode> child;
nsAutoString rtext;
aElement->GetFirstChild(getter_AddRefs(child));
while (child) {
PRUint16 type;
child->GetNodeType(&type);
if (nsIDOMNode::TEXT_NODE == type
|| nsIDOMNode::CDATA_SECTION_NODE == type) {
nsCOMPtr<nsIDOMText> text = do_QueryInterface(child);
nsAutoString data;
text->GetData(data);
rtext.Append(data);
}
else if (nsIDOMNode::ELEMENT_NODE == type) {
return NS_ERROR_ILLEGAL_VALUE; // This was interpreted as a simple value, yet had complex content in it.
}
nsCOMPtr<nsIDOMNode> temp = child;
GetNextSibling(temp, getter_AddRefs(child));
}
aText.Assign(rtext);
return NS_OK;
}
PRBool
nsSOAPUtils::HasChildElements(nsIDOMElement* aElement)
{
nsCOMPtr<nsIDOMNode> child;
aElement->GetFirstChild(getter_AddRefs(child));
while (child) {
PRUint16 type;
child->GetNodeType(&type);
if (nsIDOMNode::ELEMENT_NODE == type) {
return PR_TRUE;
}
nsCOMPtr<nsIDOMNode> temp = child;
GetNextSibling(temp, getter_AddRefs(child));
}
return PR_FALSE;
}
void
nsSOAPUtils::GetNextSibling(nsIDOMNode* aSibling, nsIDOMNode **aNext)
{
nsCOMPtr<nsIDOMNode> last;
nsCOMPtr<nsIDOMNode> current;
PRUint16 type;
*aNext = nsnull;
last = aSibling;
last->GetNodeType(&type);
if (nsIDOMNode::ENTITY_REFERENCE_NODE == type) {
last->GetFirstChild(getter_AddRefs(current));
if (!last)
{
last->GetNextSibling(getter_AddRefs(current));
}
}
else {
last->GetNextSibling(getter_AddRefs(current));
}
while (!current)
{
last->GetParentNode(getter_AddRefs(current));
current->GetNodeType(&type);
if (nsIDOMNode::ENTITY_REFERENCE_NODE == type) {
last = current;
last->GetNextSibling(getter_AddRefs(current));
}
else {
current = nsnull;
break;
}
}
*aNext = current;
NS_IF_ADDREF(*aNext);
}
nsresult nsSOAPUtils::GetNamespaceURI(nsIDOMElement* aScope,
const nsAReadableString & aQName,
nsAWritableString & aURI)
{
aURI.Truncate(0);
PRInt32 i = aQName.FindChar(':');
if (i < 0) {
return NS_OK;
}
nsAutoString prefix;
aQName.Left(prefix, i);
if (prefix.Equals(kXMLPrefix)) {
aURI.Assign(kXMLNamespaceURI);
return NS_OK;
}
nsresult rc;
nsCOMPtr<nsIDOMNode> current = aScope;
nsCOMPtr<nsIDOMNamedNodeMap> attrs;
nsCOMPtr<nsIDOMNode> temp;
nsAutoString value;
while (current != nsnull) {
rc = current->GetAttributes(getter_AddRefs(attrs));
if (NS_FAILED(rc)) return rc;
if (attrs) {
rc = attrs->GetNamedItemNS(kXMLNamespaceNamespaceURI, prefix, getter_AddRefs(temp));
if (NS_FAILED(rc)) return rc;
if (temp != nsnull)
return temp->GetNodeValue(aURI);
}
rc = current->GetParentNode(getter_AddRefs(temp));
if (NS_FAILED(rc)) return rc;
current = temp;
}
return NS_ERROR_FAILURE;
}
nsresult nsSOAPUtils::GetLocalName(const nsAReadableString & aQName,
nsAWritableString & aLocalName)
{
PRInt32 i = aQName.FindChar(':');
if (i < 0)
aLocalName = aQName;
else
aQName.Mid(aLocalName, i, aQName.Length() - i);
return NS_OK;
}
nsresult
nsSOAPUtils::MakeNamespacePrefix(nsIDOMElement* aScope,
const nsAReadableString & aURI,
nsAWritableString & aPrefix)
{
// This may change for level 3 serialization, so be sure to gut this
// and call the standardized level 3 method when it is available.
aPrefix.Truncate(0);
if (aURI.IsEmpty())
return NS_OK;
if (aURI.Equals(nsSOAPUtils::kXMLNamespaceURI)) {
aPrefix.Assign(nsSOAPUtils::kXMLPrefix);
return NS_OK;
}
nsCOMPtr<nsIDOMNode> current = aScope;
nsCOMPtr<nsIDOMNamedNodeMap> attrs;
nsCOMPtr<nsIDOMNode> temp;
nsAutoString tstr;
nsresult rc;
PRUint32 maxns = 0; // Keep track of max generated NS
for (;;) {
rc = current->GetAttributes(getter_AddRefs(attrs));
if (NS_FAILED(rc)) return rc;
if (attrs) {
PRUint32 i = 0;
for (;;)
{
attrs->Item(i++, getter_AddRefs(temp));
if (!temp)
break;
temp->GetNamespaceURI(tstr);
if (!tstr.Equals(nsSOAPUtils::kXMLNamespaceNamespaceURI))
continue;
temp->GetNodeValue(tstr);
if (tstr.Equals(aURI)) {
nsAutoString prefix;
rc = temp->GetLocalName(prefix);
if (NS_FAILED(rc)) return rc;
nsCOMPtr<nsIDOMNode> check = aScope;
PRBool hasDecl;
nsCOMPtr<nsIDOMElement> echeck;
while (check != current) { // Make sure prefix is not overridden
echeck = do_QueryInterface(check);
if (echeck) {
rc = echeck->HasAttributeNS(nsSOAPUtils::kXMLNamespaceNamespaceURI, prefix, &hasDecl);
if (NS_FAILED(rc)) return rc;
if (hasDecl)
break;
current->GetParentNode(getter_AddRefs(temp));
current = temp;
}
}
if (check == current) {
aPrefix.Assign(prefix);
return NS_OK;
}
}
rc = temp->GetLocalName(tstr);
if (NS_FAILED(rc))
return rc;
else { // Decode the generated namespace into a number
nsReadingIterator<PRUnichar> i1;
nsReadingIterator<PRUnichar> i2;
tstr.BeginReading(i1);
tstr.EndReading(i2);
if (i1 == i2 || *i1 != 'n')
continue;
i1++;
if (i1 == i2 || *i1 != 's')
continue;
i1++;
PRUint32 n = 0;
while (i1 != i2) {
PRUnichar c = *i1;
i1++;
if (c < '0' || c > '9') {
n = 0;
break;
}
n = n * 10 + (c - '0');
}
if (n > maxns)
maxns = n;
}
}
}
current->GetParentNode(getter_AddRefs(temp));
if (temp)
current = temp;
else
break;
}
// Create a unique prefix...
PRUint32 len = 3;
PRUint32 c = maxns + 1;
while (c >= 10) {
c = c / 10;
len++;
}
// Set the length and write it backwards since that's the easiest way..
aPrefix.SetLength(len);
nsWritingIterator<PRUnichar> i2;
aPrefix.EndWriting(i2);
c = maxns + 1;
while (c > 0) {
PRUint32 r = c % 10;
c = c / 10;
i2--;
*i2 = (PRUnichar)(r + '0');
}
i2--;
*i2 = 's';
i2--;
*i2 = 'n';
return NS_OK;
}
nsresult
nsSOAPUtils::MakeNamespacePrefixFixed(nsIDOMElement* aScope,
const nsAReadableString & aURI,
nsAWritableString & aPrefix)
{
if (aURI.Equals(kSOAPEncodingURI))
aPrefix = kSOAPEncodingPrefix;
else if (aURI.Equals(kSOAPEnvURI))
aPrefix = kSOAPEnvPrefix;
else if (aURI.Equals(kXSIURI))
aPrefix = kXSIPrefix;
else if (aURI.Equals(kXSDURI))
aPrefix = kXSDPrefix;
else
return MakeNamespacePrefix(aScope, aURI, aPrefix);
return NS_OK;
}
PRBool nsSOAPUtils::StartsWith(nsAReadableString& aSuper,
nsAReadableString& aSub)
{
PRUint32 c1 = aSuper.Length();
PRUint32 c2 = aSub.Length();
if (c1 < c2) return PR_FALSE;
if (c1 == c2) return aSuper.Equals(aSub);
nsReadingIterator<PRUnichar> i1;
nsReadingIterator<PRUnichar> i2;
aSuper.BeginReading(i1);
aSub.BeginReading(i2);
while (c2--) {
if (*i1 != *i2) return PR_FALSE;
i1++;
i2++;
}
return PR_TRUE;
}

View File

@@ -0,0 +1,109 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Netscape 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/NPL/
*
* Software distributed under the License is distributed on an "AS
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
* implied. See the License for the specific language governing
* rights and limitations under the License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All
* Rights Reserved.
*
* Contributor(s):
*/
#ifndef nsSOAPUtils_h__
#define nsSOAPUtils_h__
#include "nsString.h"
#include "nsIDOMElement.h"
class nsSOAPUtils {
public:
static void GetSpecificChildElement(nsIDOMElement *aParent,
const nsAReadableString& aNamespace,
const nsAReadableString& aType,
nsIDOMElement * *aElement);
static void GetSpecificSiblingElement(nsIDOMElement *aSibling,
const nsAReadableString& aNamespace,
const nsAReadableString& aType,
nsIDOMElement * *aElement);
static void GetFirstChildElement(nsIDOMElement* aParent,
nsIDOMElement** aElement);
static void GetNextSiblingElement(nsIDOMElement* aStart,
nsIDOMElement** aElement);
static nsresult GetElementTextContent(nsIDOMElement* aElement,
nsAWritableString& aText);
static PRBool HasChildElements(nsIDOMElement* aElement);
static void GetNextSibling(nsIDOMNode* aSibling,
nsIDOMNode **aNext);
static nsresult MakeNamespacePrefix(nsIDOMElement* aElement,
const nsAReadableString & aURI,
nsAWritableString & aPrefix);
static nsresult MakeNamespacePrefixFixed(nsIDOMElement* aElement,
const nsAReadableString & aURI,
nsAWritableString & aPrefix);
static nsresult GetNamespaceURI(nsIDOMElement* aElement,
const nsAReadableString & aQName,
nsAWritableString & aURI);
static nsresult GetLocalName(const nsAReadableString & aQName,
nsAWritableString & aLocalName);
// All those missing string functions have to come from somewhere...
static PRBool StartsWith(nsAReadableString& aSuper,
nsAReadableString& aSub);
static nsDependentString kSOAPEnvURI;
static nsDependentString kSOAPEncodingURI;
static nsDependentString kSOAPEnvPrefix;
static nsDependentString kSOAPEncodingPrefix;
static nsDependentString kXSIURI;
static nsDependentString kXSDURI;
static nsDependentString kXSIPrefix;
static nsDependentString kXSITypeAttribute;
static nsDependentString kXSDPrefix;
static nsDependentString kEncodingStyleAttribute;
static nsDependentString kActorAttribute;
static nsDependentString kEnvelopeTagName;
static nsDependentString kHeaderTagName;
static nsDependentString kBodyTagName;
static nsDependentString kFaultTagName;
static nsDependentString kFaultCodeTagName;
static nsDependentString kFaultStringTagName;
static nsDependentString kFaultActorTagName;
static nsDependentString kFaultDetailTagName;
static nsDependentString kEncodingSeparator;
static nsDependentString kQualifiedSeparator;
static nsDependentString kXMLNamespaceNamespaceURI;
static nsDependentString kXMLNamespaceURI;
static nsDependentString kXMLNamespacePrefix;
static nsDependentString kXMLPrefix;
};
// Used to support null strings.
inline PRBool AStringIsNull(const nsAReadableString& aString)
{
return aString.IsVoid() || aString.IsEmpty(); // Get rid of empty hack when string implementations support.
}
inline void SetAStringToNull(nsAWritableString& aString)
{
aString.Truncate();
aString.SetIsVoid(PR_TRUE);
}
#define NS_SOAP_ENSURE_ARG_STRING(arg) \
NS_ENSURE_FALSE(AStringIsNull(arg), NS_ERROR_INVALID_ARG)
#endif

View File

@@ -0,0 +1,31 @@
#
# The contents of this file are subject to the Mozilla Public
# License Version 1.1 (the "License"); you may not use this file
# except in compliance with the License. You may obtain a copy of
# the License at http://www.mozilla.org/MPL/
#
# Software distributed under the License is distributed on an "AS
# IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
# implied. See the License for the specific language governing
# rights and limitations under the License.
#
# The Original Code is mozilla.org code.
#
# The Initial Developer of the Original Code is Netscape
# Communications Corporation. Portions created by Netscape are
# Copyright (C) 1998 Netscape Communications Corporation. All
# Rights Reserved.
#
# Contributor(s):
#
DEPTH = ../../..
topsrcdir = @top_srcdir@
srcdir = @srcdir@
VPATH = @srcdir@
include $(DEPTH)/config/autoconf.mk
DIRS = public src
include $(topsrcdir)/config/rules.mk

View File

@@ -0,0 +1,26 @@
#!nmake
#
# The contents of this file are subject to the Netscape 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/NPL/
#
# Software distributed under the License is distributed on an "AS
# IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
# implied. See the License for the specific language governing
# rights and limitations under the License.
#
# The Original Code is mozilla.org code.
#
# The Initial Developer of the Original Code is Netscape
# Communications Corporation. Portions created by Netscape are
# Copyright (C) 1998 Netscape Communications Corporation. All
# Rights Reserved.
#
# Contributor(s):
DEPTH=..\..\..
DIRS=public src
include <$(DEPTH)\config\rules.mak>

View File

@@ -0,0 +1,19 @@
#
# This is a list of local files which get copied to the mozilla:dist:idl directory
#
nsISOAPAttachments.idl
nsISOAPCall.idl
nsISOAPDecoder.idl
nsISOAPEncoder.idl
nsISOAPEncoding.idl
nsISOAPFault.idl
nsISOAPHeaderBlock.idl
nsISOAPMessage.idl
nsISOAPParameter.idl
nsISOAPResponse.idl
nsISOAPResponseListener.idl
nsISOAPService.idl
nsISOAPServiceRegistry.idl
nsISOAPTransport.idl
nsISOAPTransportListener.idl

View File

@@ -0,0 +1,50 @@
#
# The contents of this file are subject to the Mozilla Public
# License Version 1.1 (the "License"); you may not use this file
# except in compliance with the License. You may obtain a copy of
# the License at http://www.mozilla.org/MPL/
#
# Software distributed under the License is distributed on an "AS
# IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
# implied. See the License for the specific language governing
# rights and limitations under the License.
#
# The Original Code is mozilla.org code.
#
# The Initial Developer of the Original Code is Netscape
# Communications Corporation. Portions created by Netscape are
# Copyright (C) 1998 Netscape Communications Corporation. All
# Rights Reserved.
#
# Contributor(s):
#
DEPTH = ../../../..
topsrcdir = @top_srcdir@
srcdir = @srcdir@
VPATH = @srcdir@
include $(DEPTH)/config/autoconf.mk
MODULE = xmlextras
XPIDL_MODULE = xmlsoap
XPIDLSRCS = \
nsISOAPAttachments.idl \
nsISOAPCall.idl \
nsISOAPDecoder.idl \
nsISOAPEncoder.idl \
nsISOAPEncoding.idl \
nsISOAPFault.idl \
nsISOAPHeaderBlock.idl \
nsISOAPMessage.idl \
nsISOAPParameter.idl \
nsISOAPResponse.idl \
nsISOAPResponseListener.idl \
nsISOAPService.idl \
nsISOAPServiceRegistry.idl \
nsISOAPTransport.idl \
nsISOAPTransportListener.idl \
$(NULL)
include $(topsrcdir)/config/rules.mk

View File

@@ -0,0 +1,46 @@
#!nmake
#
# The contents of this file are subject to the Netscape 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/NPL/
#
# Software distributed under the License is distributed on an "AS
# IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
# implied. See the License for the specific language governing
# rights and limitations under the License.
#
# The Original Code is mozilla.org code.
#
# The Initial Developer of the Original Code is Netscape
# Communications Corporation. Portions created by Netscape are
# Copyright (C) 1998 Netscape Communications Corporation. All
# Rights Reserved.
#
# Contributor(s):
DEPTH=..\..\..\..
MODULE = xmlextras
XPIDL_MODULE = xmlsoap
XPIDLSRCS = \
.\nsISOAPAttachments.idl \
.\nsISOAPCall.idl \
.\nsISOAPDecoder.idl \
.\nsISOAPEncoder.idl \
.\nsISOAPEncoding.idl \
.\nsISOAPFault.idl \
.\nsISOAPHeaderBlock.idl \
.\nsISOAPMessage.idl \
.\nsISOAPParameter.idl \
.\nsISOAPResponse.idl \
.\nsISOAPResponseListener.idl \
.\nsISOAPService.idl \
.\nsISOAPServiceRegistry.idl \
.\nsISOAPTransport.idl \
.\nsISOAPTransportListener.idl \
$(NULL)
include <$(DEPTH)\config\rules.mak>

View File

@@ -0,0 +1,50 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Netscape 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/NPL/
*
* Software distributed under the License is distributed on an "AS
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
* implied. See the License for the specific language governing
* rights and limitations under the License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 2001 Netscape Communications Corporation. All
* Rights Reserved.
*
* Contributor(s):
*/
#include "nsISupports.idl"
/**
* This interface permits attachment of SOAP attachments.
*/
[scriptable, uuid(6192dcbe-1dd2-11b2-81ad-a4597614c4ae)]
interface nsISOAPAttachments : nsISupports {
/**
* Get the attachment associated with a particular identifier.
*
* @param aIdentifier The identifier of the attachment to be accessed.
*
* Appropriate return(s) must be identified.
*/
void getAttachment(in AString aIdentifier);
/**
* Attach an attachment to the message.
*
* Appropriate argument(s) must be identified.
*
* @return The identifier of the attachment, to be referenced in SOAP encoding
*/
AString attach();
};

View File

@@ -0,0 +1,90 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Netscape 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/NPL/
*
* Software distributed under the License is distributed on an "AS
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
* implied. See the License for the specific language governing
* rights and limitations under the License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 2001 Netscape Communications Corporation. All
* Rights Reserved.
*
* Contributor(s):
*/
#include "nsISupports.idl"
#include "nsISOAPMessage.idl"
interface nsISOAPResponse;
interface nsISOAPResponseListener;
/**
* This interface is a convenience extension of the basic SOAP message,
* which handles common patterns of calling, such as providing an
* action URI in the HTTP header, locating and invoking the appropriate
* transport based upon the protocol of the transportURI, and
* automatically recieving the result in a new nsISOAPResponse object
* which recieves an XML message.
*/
[scriptable, uuid(a8fefe40-52bc-11d4-9a57-000064657374)]
interface nsISOAPCall : nsISOAPMessage {
/**
* The URI to which the message will be sent, identifying the
* transport and transport-specific information about the
* destination.
* This does not have to match the <code>targetObjectURI</code>.
*/
attribute AString transportURI;
/**
* Synchronously invoke the call. The method returns only when
* we receive a response (or an error occurs). The
* <code>transportURI</code> must have been set, the
* parameter list (even if empty) must have been encoded,
* and the transportURI must use some known protocol. A
* synchronous call assumes that there will be exactly one
* response per call.
*
* If not, an error is returned in the status of the response.
*
* @returns The SOAP response
*/
nsISOAPResponse invoke();
/**
* Asynchronously invoke the call. At this point, the document
* rooted by the Envelope element is encoded to form the body
* of the SOAP message. The method returns immediately, and the
* listener is invoked when we eventually receive a response
* (or error or successful completion). The
* <code>transportURI</code> must have been set, the
* parameter list (even if empty) must have been encoded,
* and the transportURI must use some known protocol.
*
* If not, an error is returned in the status of the response.
*
* @param aListener Handler to be invoked asynchronously after the
* response is recieved. Should be null if no response is
* expected.
*/
void asyncInvoke(in nsISOAPResponseListener aListener);
};
%{ C++
#define NS_SOAPCALL_CID \
{ /* 87d21ec0-539d-11d4-9a59-00104bdf5339 */ \
0x87d21ec0, 0x539d, 0x11d4, \
{0x9a, 0x59, 0x00, 0x10, 0x4b, 0xdf, 0x53, 0x39} }
#define NS_SOAPCALL_CONTRACTID \
"@mozilla.org/xmlextras/soap/call;1"
%}

View File

@@ -0,0 +1,61 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Netscape 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/NPL/
*
* Software distributed under the License is distributed on an "AS
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
* implied. See the License for the specific language governing
* rights and limitations under the License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 2001 Netscape Communications Corporation. All
* Rights Reserved.
*
* Contributor(s):
*/
#include "nsISupports.idl"
interface nsISchemaType;
interface nsISOAPEncoding;
interface nsIDOMElement;
interface nsIVariant;
interface nsISOAPAttachments;
/**
* This interface supplies decoding of a specific
* part of a message XML DOM into appropriate objects
* for the script or application.
*/
[scriptable, uuid(4c2e02ae-1dd2-11b2-b1cd-c79dea3d46db)]
interface nsISOAPDecoder : nsISupports {
/**
* Decode the source DOM node
*
* @param aEncodings The encodings used to decode
*
* @param aEncodingStyleURI The encoding style
*
* @param aSource The DOM node to be decoded.
*
* @param aSchemaType The schema type of the source DOM node
*
* @param aAttachments Dispenses any attachments.
*
* @return The decoded variant, which is null if
* the operation failed or did not return a result.
*/
nsIVariant decode(
in nsISOAPEncoding aEncoding,
in nsIDOMElement aSource,
in nsISchemaType aSchemaType,
in nsISOAPAttachments aAttachments);
};

View File

@@ -0,0 +1,69 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Netscape 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/NPL/
*
* Software distributed under the License is distributed on an "AS
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
* implied. See the License for the specific language governing
* rights and limitations under the License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 2001 Netscape Communications Corporation. All
* Rights Reserved.
*
* Contributor(s):
*/
#include "nsISupports.idl"
interface nsISchemaType;
interface nsISOAPEncoding;
interface nsIVariant;
interface nsIDOMElement;
interface nsISOAPAttachments;
/**
* This interface permits encoding of variants.
*/
[scriptable, uuid(fc33ffd6-1dd1-11b2-8750-fa62430a38b4)]
interface nsISOAPEncoder : nsISupports {
/**
* Encode the source variant.
*
* @param aEncodings The encodings to be used.
*
* @param aEncodingStyleURI The encoding style
*
* @param aSource The variant to be encoded.
*
* @param aNamespaceURI The namespace of the thing being coded
*
* @param aName The name of the thing being coded
*
* @param aSchemaType The schema type of the thing being encoded
*
* @param aDestination The node scope, if any, where the result
* will live. If this is null, then the result must be
* explicitly attached to the message.
*
* @return element which was inserted.
*
* @param aAttachments Accumulates any attachments.
*/
nsIDOMElement encode(
in nsISOAPEncoding aEncoding,
in nsIVariant aSource,
in AString aNamespaceURI,
in AString aName,
in nsISchemaType aSchemaType,
in nsISOAPAttachments aAttachments,
in nsIDOMElement aDestination);
};

View File

@@ -0,0 +1,184 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Netscape 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/NPL/
*
* Software distributed under the License is distributed on an "AS
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
* implied. See the License for the specific language governing
* rights and limitations under the License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 2001 Netscape Communications Corporation. All
* Rights Reserved.
*
* Contributor(s):
*/
#include "nsISupports.idl"
interface nsISchemaType;
interface nsIDOMElement;
interface nsISOAPEncoder;
interface nsISOAPDecoder;
interface nsISOAPMessage;
interface nsIVariant;
interface nsISOAPAttachments;
interface nsISchemaCollection;
/**
* This interface keeps track of all the known types and how
* each should be encoded (by type) or decoded (by
* schema type)
*/
[scriptable, uuid(9ae49600-1dd1-11b2-877f-e62f620c5e92)]
interface nsISOAPEncoding : nsISupports {
/**
* The name of the encoding as it is known to SOAP.
*/
readonly attribute AString styleURI;
/**
* Get an alternative encoding.
*
* @param aStyleURI The style URI of the alternative encoding style.
*
* @param aCreateIf If true, then create the alternative style if it
* does not already exist, otherwise return the existing encoding.
*
* @return The alternative encoding which corresponds to the
* specified styleURI, or null if the spefied alternative encoding
* does not exist and it was not requested that it be created.
*/
nsISOAPEncoding getStyle(
in AString aStyleURI,
in boolean aCreateIf);
/**
* Set an encoder in the encoding.
*
* @param aSchemaNamespaceURI The schema namespace URI to serve as key.
*
* @param aSchemaType The schema type to serve as key.
*
* @param aEncoder The encoder to be specified or null to eliminate
* the encoder.
*
* @return Old encoder registered under that type in the encoding, which
* should be kept by the new encoder if it is to be called back.
*/
void setEncoder(in AString aSchemaNamespaceURI, in AString aSchemaType,
in nsISOAPEncoder aEncoder);
/**
* Get an encoder from the encoding.
*
* @param aSchemaNamespaceURI The schema namespace URI to serve as key.
*
* @param aSchemaType The schema type to serve as key.
*
* @return The encoder.
*/
nsISOAPEncoder getEncoder(in AString aSchemaNamespaceURI, in AString aSchemaType);
/**
* Set a decoder in the encoding.
*
* @param aSchemaNamespaceURI The schema namespace URI to serve as key.
*
* @param aSchemaType The schema type to serve as key.
*
* @param aDecoder The decoder to be specified or null to eliminate
* the decoder.
*
* @return Old decoder registered under that type in the encoding, which
* should be kept by the new decoder if it is to be called back.
*/
void setDecoder(in AString aSchemaNamespaceURI, in AString aSchemaType,
in nsISOAPDecoder aDecoder);
/**
* Get a decoder from the encoding.
*
* @param aSchemaNamespaceURI The schema namespace URI to serve as key.
*
* @param aSchemaType The schema type to serve as key.
*
* @return The decoder.
*/
nsISOAPDecoder getDecoder(in AString aSchemaNamespaceURI, in AString aSchemaType);
attribute nsISOAPEncoder defaultEncoder;
attribute nsISOAPDecoder defaultDecoder;
attribute nsISchemaCollection schemaCollection;
/**
* Encode the source variant
*
* @param aEncodings The encodings to be used.
*
* @param aEncodingStyleURI The encoding style
*
* @param aSource The variant to be encoded, soon to become a variant
*
* @param aNamespaceURI The namespace of the thing being coded
*
* @param aName The name of the thing being coded
*
* @param aSchemaType The schema type of the thing being encoded
*
* @param aDestination The node scope where the result will live.
*
* @param aAttachments Accumulates any attachments.
*
* @return The element which was inserted and encoded.
*/
nsIDOMElement encode(
in nsIVariant aSource,
in AString aNamespaceURI,
in AString aName,
in nsISchemaType aSchemaType,
in nsISOAPAttachments aAttachments,
in nsIDOMElement aDestination);
/**
* Decode the source DOM node
*
* @param aEncodings The encodings used to decode
*
* @param aEncodingStyleURI The encoding style
*
* @param aSource The DOM node to be decoded.
*
* @param aSchemaType The schema type of the source DOM node
*
* @param aAttachments Dispenses any attachments.
*
* @return The decoded variant, soon to become a variant, which is null if
* the operation failed or did not return a result.
*/
nsIVariant decode(
in nsIDOMElement aSource,
in nsISchemaType aSchemaType,
in nsISOAPAttachments aAttachments);
};
%{ C++
#define NS_DEFAULTSOAPENCODER_CID \
{ /* 06fb035c-1dd2-11b2-bc30-f6d8e314d6b9 */ \
0x06fb035c, 0x1dd2, 0x11b2, \
{0xbc, 0x30, 0xf6, 0xd8, 0xe3, 0x14, 0xd6, 0xb9} }
#define NS_SOAPENCODING_CONTRACTID_PREFIX \
"@mozilla.org/xmlextras/soap/encoding;1?uri="
#define NS_DEFAULTSOAPENCODER_CONTRACTID \
NS_SOAPENCODING_CONTRACTID_PREFIX "http://schemas.xmlsoap.org/soap/encoding/"
%}

View File

@@ -0,0 +1,69 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Netscape 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/NPL/
*
* Software distributed under the License is distributed on an "AS
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
* implied. See the License for the specific language governing
* rights and limitations under the License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 2001 Netscape Communications Corporation. All
* Rights Reserved.
*
* Contributor(s):
*/
#include "nsISupports.idl"
interface nsIDOMElement;
/**
* This interface conveniently interprets information about a fault
* that has been returned in a response message.
*
*/
[scriptable, uuid(99ec6694-535f-11d4-9a58-000064657374)]
interface nsISOAPFault : nsISupports {
/**
* The DOM element representing the fault in the response SOAP message.
* This must be set for the rest of the interface to function correctly.
*/
attribute nsIDOMElement element;
/**
* The fault code
*/
readonly attribute AString faultCode;
/**
* The fault string
*/
readonly attribute AString faultString;
/**
* The fault actor if one was specified.
*/
readonly attribute AString faultActor;
/**
* The DOM element representing the fault details
*/
readonly attribute nsIDOMElement detail;
};
%{ C++
#define NS_SOAPFAULT_CID \
{ /* 87d21ec1-539d-11d4-9a59-00104bdf5339 */ \
0x87d21ec1, 0x539d, 0x11d4, \
{0x9a, 0x59, 0x00, 0x10, 0x4b, 0xdf, 0x53, 0x39} }
#define NS_SOAPFAULT_CONTRACTID \
"@mozilla.org/xmlextras/soap/fault;1"
%}

View File

@@ -0,0 +1,96 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Netscape 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/NPL/
*
* Software distributed under the License is distributed on an "AS
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
* implied. See the License for the specific language governing
* rights and limitations under the License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 2001 Netscape Communications Corporation. All
* Rights Reserved.
*
* Contributor(s):
*/
#include "nsISupports.idl"
interface nsIDOMElement;
interface nsIVariant;
interface nsISOAPEncoding;
interface nsISchemaType;
interface nsISOAPAttachments;
/**
* This interface encapsulates an arbitrary header block to be used
* by the soap serialization or protocol. It formalizes a type
* string, a reference to the object, and a name.
*/
[scriptable, uuid(063d4a4e-1dd2-11b2-a365-cbaf1651f140)]
interface nsISOAPHeaderBlock : nsISupports {
/**
* The namespace URI of the header block. Ignored if name is null.
*/
attribute AString namespaceURI;
/**
* The name of the header block. If the header block is left unnamed, it
* will be encoded using the element types defined in the SOAP-ENC
* schema. For example, <code>&lt;SOAP-ENC:int&gt;45&lt;/SOAP-ENC:int&gt;
* </code>
*/
attribute AString name;
/**
* The actor URI of the header block.
*/
attribute AString actorURI;
/**
* The encoding that was / will be applied to the
* header block.
*/
attribute nsISOAPEncoding encoding;
/**
* The schema type used to encode or decode the
* header block.
*/
attribute nsISchemaType schemaType;
/**
* The element which is the encoded value of this header block.
* If this is set, value becomes a computed attribute
* which is produced by decoding this element.
*/
attribute nsIDOMElement element;
/**
* The native value which is the decoded value of
* this header block. If this is set, element becomes null.
*/
attribute nsIVariant value;
/**
* The attachments which were attached to the message.
*/
attribute nsISOAPAttachments attachments;
};
%{ C++
#define NS_SOAPHEADERBLOCK_CID \
{ /* 5ad0eace-1dd2-11b2-a260-ff42edcaedb3 */ \
0x5ad0eace, 0x1dd2, 0x11b2, \
{0xa2, 0x60, 0xff, 0x42, 0xed, 0xca, 0xed, 0xb3} }
#define NS_SOAPHEADERBLOCK_CONTRACTID \
"@mozilla.org/xmlextras/soap/headerblock;1"
%}

View File

@@ -0,0 +1,196 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Netscape 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/NPL/
*
* Software distributed under the License is distributed on an "AS
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
* implied. See the License for the specific language governing
* rights and limitations under the License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 2001 Netscape Communications Corporation. All
* Rights Reserved.
*
* Contributor(s):
*/
#include "nsISupports.idl"
interface nsIDOMDocument;
interface nsIDOMElement;
interface nsISOAPEncoding;
interface nsISOAPHeaderBlock;
interface nsISOAPParameter;
interface nsIVariant;
/**
* This interface controls all SOAP messages. It permits easy
* construction of a message, typically through encoding of
* parameters and certain properties settable on this interface
* or through deserialization of a transport stream. It
* permits easy processing of a message typically through
* decoding of parameters and certain properties available
* on this interface. It also encapsulates protocol information
* interpreted by the transport.
*/
[scriptable, uuid(3970815e-1dd2-11b2-a475-db4dac6826f1)]
interface nsISOAPMessage : nsISupports {
/**
* The document which captures the message, if any. A simple
* sending application passes parameters to the method
* encodeSOAPParameters, which calls SOAP encoders
* to construct this document along with all contained elements.
*
* But an application may create and set the message directly
* instead of invoking encodeSOAPParameters to use encoders
* or access and manipulate the message after it has been
* constructed by encodeSOAPParameters. If the message has
* not been set, invoking a call will fail. A message reciever
* may also use this accessor to get the document to avoid using
* decoders.
*/
attribute nsIDOMDocument message;
/**
* A convenience attribute to obtain the DOM element representing the
* SOAP envelope from the document. DOM methods may be used to
* access, add, or modify attributes of the envelope.
*
* If the message attribute is null or is not a document containing
* a root soap envelope element, then this will be null.
*/
readonly attribute nsIDOMElement envelope;
/**
* A convenience attribute to obtain the DOM element representing the
* SOAP header from the envelope. DOM methods may be used to
* access, add, or modify attributes or elements of the header.
*
* If the envelope attribute is null or does not contain a SOAP header
* element type, then this will be null.
*/
readonly attribute nsIDOMElement header;
/**
* A convenience attribute to obtain the DOM element representing the
* SOAP body from the envelope. DOM methods may be used to
* access, add, or modify attributes or elements of the body.
*
* If the envelope attribute is null or does not contain a SOAP body
* element type, then this will be null.
*/
readonly attribute nsIDOMElement body;
/**
* The name of the method being invoked. The methodName is set
* during encoding as the tagname of the single child of body
* of RPC-style messages. When there is no encoded message
* this will be null. The value of this attribute for
* document-style messages may be non-null but should be
* ignored. It is up to the application to know whether the
* message is RPC-style or document style because the SOAP
* specification makes it difficult to tell which way a
* message was encoded.
*/
readonly attribute AString methodName;
/**
* The target object on which the method is being invoked. This URI
* is set during encoding as the namespace to qualify the tagname
* of the single child of body of RPC-style messages. When there
* is no encoded message, this will be null. The value of this
* attribute for document-style messages may be non-null but should
* be ignored. It is up to the application to know whether the
* message is RPC-style or document style because the SOAP
* specification makes it difficult to tell which way a
* message was encoded.
*/
readonly attribute AString targetObjectURI;
/**
* Encodes the specified parameters into this message, if
* this message type supports it.
*
* @param aMethodName The name of the method being invoked
* for rpc-style messages. For document-style messages,
* this must be null.
*
* @param aTargetObjectURI The name of the target object
* for rpc-style messages. For document-style messages,
* this must be null.
*
* @param aHeaderBlockCount Number of header blocks in array to be
* encoded. Must be 0 if header block array is null.
*
* @param aHeaderBlocks Array of header blocks to be encoded, which
* may be null if there are no header blocks.
*
* @param aParameterCount Number of parameters in array
* to be encoded. Must be 0 if parameter array is null.
*
* @param aParameters An array of parameters to be
* encoded, which may null if there are no parameters.
*/
void encode(
in AString aMethodName, in AString aTargetObjectURI,
in PRUint32 aHeaderBlockCount,
[array, size_is(aHeaderBlockCount)] in nsISOAPHeaderBlock aHeaderBlocks,
in PRUint32 aParameterCount,
[array, size_is(aParameterCount)] in nsISOAPParameter aParameters);
/**
* Gathers the header blocks of a message so that they can be
* accessed by a recipient.
*
* @param aCount Integer to receive the length of the list
* of header blocks.
*
* @return Array of header blocks found in the message.
*/
void getHeaderBlocks(out PRUint32 aCount,
[array, size_is(aCount), retval] out nsISOAPHeaderBlock aHeaderBlocks);
/**
* Gathers the parameters of a message so that they can be
* accessed by a recipient.
*
* @param aDocumentStyle If true, then the parameters
* are looked for treating the message as a document
* style message, otherwise it treated as an RPC-style
* message.
*
* @param aCount Integer to receive the length of the list
* of parameters.
*
* @return Array of parameters found in the message.
*/
void getParameters(in boolean aDocumentStyle,
out PRUint32 aCount,
[array, size_is(aCount), retval] out nsISOAPParameter aParameters);
/**
* The primary encoding of the message, which is established
* at the envelope and used unless overridden. By default,
* this is the SOAP encoding, which may be locally modified
* or used to obtain alternative encodings, which may be
* locally modified, but it may be set to an encoding that
* is shared, or it may be set to null, in which case all
* non-literal header blocks and parameters must specify an
* encoding.
*/
attribute nsISOAPEncoding encoding;
/**
* An optional URI that can be used to add a SOAPAction HTTP
* header field. If this attribute is NULL (the default case),
* no SOAPAction header will be added.
*/
attribute AString actionURI;
};

View File

@@ -0,0 +1,93 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Netscape 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/NPL/
*
* Software distributed under the License is distributed on an "AS
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
* implied. See the License for the specific language governing
* rights and limitations under the License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 2001 Netscape Communications Corporation. All
* Rights Reserved.
*
* Contributor(s):
*/
#include "nsISupports.idl"
interface nsIDOMElement;
interface nsIVariant;
interface nsISOAPEncoding;
interface nsISchemaType;
interface nsISOAPAttachments;
/**
* This interface encapsulates an arbitrary parameter to be used
* by the soap serialization or protocol. It formalizes a type
* string, a reference to the object, and a name.
*/
[scriptable, uuid(99ec6690-535f-11d4-9a58-000064657374)]
interface nsISOAPParameter : nsISupports {
/**
* The namespace URI of the parameter. Ignored if name is null.
*/
attribute AString namespaceURI;
/**
* The name of the parameter. If the parameter is left unnamed, it
* will be encoded using the element types defined in the SOAP-ENC
* schema. For example, <code>&lt;SOAP-ENC:int&gt;45&lt;/SOAP-ENC:int&gt;
* </code>
*/
attribute AString name;
/**
* The encoding that was / will be applied to the
* parameter.
*/
attribute nsISOAPEncoding encoding;
/**
* The schema type used to encode or decode the
* parameter.
*/
attribute nsISchemaType schemaType;
/**
* The element which is the encoded value of this parameter.
* If this is set, value becomes a computed attribute
* which may be produced by decoding this element.
*/
attribute nsIDOMElement element;
/**
* The native value which is the decoded value of
* this parameter. If this is set, element becomes
* null.
*/
attribute nsIVariant value;
/**
* The attachments which were attached to the message
* that may be needed to decode the parameter.
*/
attribute nsISOAPAttachments attachments;
};
%{ C++
#define NS_SOAPPARAMETER_CID \
{ /* 87d21ec2-539d-11d4-9a59-00104bdf5339 */ \
0x87d21ec2, 0x539d, 0x11d4, \
{0x9a, 0x59, 0x00, 0x10, 0x4b, 0xdf, 0x53, 0x39} }
#define NS_SOAPPARAMETER_CONTRACTID \
"@mozilla.org/xmlextras/soap/parameter;1"
%}

View File

@@ -0,0 +1,63 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Netscape 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/NPL/
*
* Software distributed under the License is distributed on an "AS
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
* implied. See the License for the specific language governing
* rights and limitations under the License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 2001 Netscape Communications Corporation. All
* Rights Reserved.
*
* Contributor(s):
*/
#include "nsISupports.idl"
#include "nsISOAPCall.idl"
interface nsISOAPParameter;
interface nsISOAPFault;
/**
* This is an extension of a message which contains extra functions
* such as tracking, where appropriate, the original call that
* produced the response message, identifying the fault, if any,
* and supplying the return value.
*/
[scriptable, uuid(99ec6691-535f-11d4-9a58-000064657374)]
interface nsISOAPResponse : nsISOAPMessage {
/**
* The message which generated this response. There is no guarantee
* that the message has not been modified since the original call
* occurred. This is set automatically when invoking a call that
* returns this response. This must also be set by a call processor
* so that the transport can return a response to the correct caller.
*/
attribute nsISOAPCall respondingTo;
/**
* The fault returned in the response, if one was generated. NULL
* if there was no fault. This does not rely on the response
* parameters having been deserialized.
*/
readonly attribute nsISOAPFault fault;
};
%{ C++
#define NS_SOAPRESPONSE_CID \
{ /* 87d21ec3-539d-11d4-9a59-00104bdf5339 */ \
0x87d21ec3, 0x539d, 0x11d4, \
{0x9a, 0x59, 0x00, 0x10, 0x4b, 0xdf, 0x53, 0x39} }
#define NS_SOAPRESPONSE_CONTRACTID \
"@mozilla.org/xmlextras/soap/response;1"
%}

View File

@@ -0,0 +1,61 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Netscape 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/NPL/
*
* Software distributed under the License is distributed on an "AS
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
* implied. See the License for the specific language governing
* rights and limitations under the License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 2001 Netscape Communications Corporation. All
* Rights Reserved.
*
* Contributor(s):
*/
#include "nsISupports.idl"
interface nsISOAPCall;
interface nsISOAPResponse;
/**
* This interface represents a response handler to be invoked whenever
* a response of a particular call is recieved and when no more
* responses are expected.
*/
[scriptable, uuid(99ec6692-535f-11d4-9a58-000064657374)]
interface nsISOAPResponseListener : nsISupports {
/**
* This method is invoked when we receive an asynchronous response to
* a SOAP message. The listener is registered as part of the original
* asynchronous call invocation.
*
* @param aResponse The decoded version of the response. If an
* error occurred transmitting the response, the status field
* of the response will contain an error code. The last call
* to the listener may contain a null response, which should
* only be interpreted as an error if your call expected more
* results than it got. If the service or the transport
* do not know whether to expect more results, then setting
* the last parameter true may only be possible after the
* last response has already been delivered.
*
* @param aLast True if this is the last call to the listener.
*
* @return True to make this the last call to the listener, even
* if last was not true. Calls which expect a single response
* should return true upon receiving that response to avoid
* possibly recieving another callback with a null response
* indicating that the last response was already sent.
*/
boolean handleResponse(in nsISOAPResponse aResponse,
in nsISOAPCall aCall, in unsigned long status, in boolean aLast);
};

View File

@@ -0,0 +1,65 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Netscape 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/NPL/
*
* Software distributed under the License is distributed on an "AS
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
* implied. See the License for the specific language governing
* rights and limitations under the License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 2001 Netscape Communications Corporation. All
* Rights Reserved.
*
* Contributor(s):
*/
#include "nsISupports.idl"
interface nsISOAPMessage;
interface nsISOAPResponseListener;
/**
* This interface describes a service which may be
* applied to incoming messages. The service is
* responsible for determining whether the message
* is one that it should process and rejecting it
* if it is not. Services may be chained.
*/
[scriptable, uuid(9927fa40-1dd1-11b2-a8d1-857ad21b872c)]
interface nsISOAPService : nsISupports {
/**
* Configuration object that may contain more info on the service
*/
attribute nsISupports configuration;
/**
* Process an incoming message.
*
* @param aMessage message to be processed
*
* @param aListener listener to which to report results
*
* @return True if the message will be handled, false if
* it should be given to some other service or fail.
* In case of failure, a more detailed status will be
* recorded in the message.
*/
boolean process(in nsISOAPMessage aMessage,
in nsISOAPResponseListener aListener);
};
%{ C++
#define NS_SOAPJSSERVICE_CID \
{ /* 26a41df2-1dd2-11b2-9f29-909e637afa0e */ \
0x26a41df2, 0x1dd2, 0x11b2, \
{0x9f, 0x29, 0x90, 0x9e, 0x63, 0x7a, 0xfa, 0x0e} }
#define NS_SOAPJSSERVICE_CONTRACTID \
"@mozilla.org/xmlextras/soap/jsservice;1"
%}

View File

@@ -0,0 +1,93 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Netscape 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/NPL/
*
* Software distributed under the License is distributed on an "AS
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
* implied. See the License for the specific language governing
* rights and limitations under the License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 2001 Netscape Communications Corporation. All
* Rights Reserved.
*
* Contributor(s):
*/
#include "nsISupports.idl"
interface nsIDOMElement;
interface nsISOAPService;
interface nsISOAPEncodingRegistry;
/**
* This interface represents a registry of SOAP services.
* This registry recieves transports to listen for messages
* and services to hand the messages to. Service registries
* may be created as required. Destroying a service registry
* stops the registry's action. To temporarily register
* services, create a new registry. For proper order of
* listening precedence, registries should be destroyed
* in reverse order. Otherwise, a listening priority
* would be required.
*/
[scriptable, uuid(9790d6bc-1dd1-11b2-afe0-bcb310c078bf)]
interface nsISOAPServiceRegistry {
/**
* Process a configuration and add the resulting sources
* and services. This will fail if errors occur during
* processing of the configuration.
*
* @param aConfiguration Root element of configuration XML.
*/
boolean addConfiguration(in nsIDOMElement aConfiguration);
/**
* Add a transport to be serviced by the registered services.
* This will fail if the specified source was already added
* with the same setting of the capture flag.
*
* @param aTransport string specifying the transport to supply
* messages for the service.
*
* @param aCapture True if capturing before later declarations
*/
void addSource(in AString aTransport, in boolean aCapture);
/**
* Add a service to service the registered transports. This
* will fail if the specified service was already added.
*
* @param aService Service to be serviced.
*/
void addService(in nsISOAPService aService);
/**
* Registry identifying how to encode and decode
* messages containing specific types, automatically
* added to messages sent to services in this
* registry.
*/
attribute nsISOAPEncodingRegistry encodings;
};
%{ C++
#define NS_SOAPSERVICEREGISTRY_CID \
{ /* 3869184e-1dd2-11b2-aa36-d8333498043a */ \
0x3869184e, 0x1dd2, 0x11b2, \
{0xaa, 0x36, 0xd8, 0x33, 0x34, 0x98, 0x04, 0x3a} }
#define NS_SOAPSERVICEREGISTRY_CONTRACTID \
"@mozilla.org/xmlextras/soap/serviceregistry;1"
#define NS_SOAPDEFAULTSERVICEREGISTRY_CID \
{ /* 9120a01e-1dd2-11b2-a61f-906766927a4f */ \
0x9120a01e, 0x1dd2, 0x11b2, \
{0xa6, 0x1f, 0x90, 0x67, 0x66, 0x92, 0x7a, 0x4f} }
#define NS_SOAPDEFAULTSERVICEREGISTRY_CONTRACTID \
"@mozilla.org/xmlextras/soap/defaultserviceregistry;1"
%}

View File

@@ -0,0 +1,102 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Netscape 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/NPL/
*
* Software distributed under the License is distributed on an "AS
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
* implied. See the License for the specific language governing
* rights and limitations under the License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 2001 Netscape Communications Corporation. All
* Rights Reserved.
*
* Contributor(s):
*/
#include "nsISupports.idl"
interface nsISOAPTransportListener;
interface nsISOAPCall;
interface nsISOAPResponse;
interface nsISOAPResponseListener;
[scriptable, uuid(99ec6695-535f-11d4-9a58-000064657374)]
interface nsISOAPTransport : nsISupports {
/**
* Send the specified message to the specified destination.
* This will fail if synchronous calls are not supported or if there is any
* failure in the actual message exchange. Failure of the call itself will be
* contained in the response.
*
* @param aCall Actual message to be sent.
*
* @param aResponse Message to be recieved. Calling synchronously assumes that
* exactly one response is expected.
*/
void syncCall( in nsISOAPCall aCall,
in nsISOAPResponse aResponse);
/**
* Send the specified message to the specified destination synchronously waiting
* for completion and any response.
* This will fail if there is any failure in the setup of the message exchange.
* Later errors will only be known through the response listener. Failures of the
* call itself will be contained in the response passed to the response listener.
*
* @param aCall Actual message to be sent.
*
* @param aListener Handler to be invoked (single threaded) as each response is
* received and finally with null. If specified as null, no responses are returned.
*
* @param response Message to recieve response and be handled by listener. May be
* null if listener is null.
*/
void asyncCall(in nsISOAPCall aCall,
in nsISOAPResponseListener aListener,
in nsISOAPResponse aResponse);
/**
* Add listener for unsolicited messages arriving on the transport. Listeners
* are provided with the opportunity to accept and process messages. Typically
* a listener will be a service dispatcher. Listeners will be invoked in the
* reverse order of declaration, allowing more local service dispatchers to
* temporarily override permanent service dispatchers. This will fail if the
* desired listener was already added to the transport with the specified
* capture flag or if the transport does not support incoming messages.
*
* @param aListener The listener to recieve unsolicited messages from the
* transport.
*
* @param aCapture True if the listener should capture the message before
* later-declared services.
*/
void addListener(in nsISOAPTransportListener aListener, in boolean aCapture);
/**
* Remove listener for unsolicited messages arriving on the transport. This
* will fail if the specified listener was not added with the specified
* capture setting.
*
* @param aListener The listener to stop from recieving unsolicited messages
* from the transport.
*
* @param aCapture True if the listener was added to capture the message before
* later-declared services (must be specified to remove, since a listener
* may be registered as both).
*/
void removeListener(in nsISOAPTransportListener aListener, in boolean aCapture);
};
%{ C++
#define NS_SOAPTRANSPORT_CONTRACTID \
"@mozilla.org/xmlextras/soap/transport;1"
#define NS_SOAPTRANSPORT_CONTRACTID_PREFIX NS_SOAPTRANSPORT_CONTRACTID "?protocol="
%}

View File

@@ -0,0 +1,50 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Netscape 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/NPL/
*
* Software distributed under the License is distributed on an "AS
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
* implied. See the License for the specific language governing
* rights and limitations under the License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 2001 Netscape Communications Corporation. All
* Rights Reserved.
*
* Contributor(s):
*/
#include "nsISupports.idl"
interface nsIDOMDocument;
interface nsISOAPMessage;
/**
* This interface recieves control when an unsolicited transport
* is recieved on a transport.
*/
[scriptable, uuid(99ec6696-535f-11d4-9a58-000064657374)]
interface nsISOAPTransportListener : nsISupports {
/**
* This method is invoked when an unsolicited message is
* recieved. First all listeners are tried in the order declared
* with the capture flag set. Then all listeners are tried in
* the reverse order declared with the capture flag clear.
*
* @param aMessage Actual message.
*
* @param aCapture True if the listener is being permitted to gain
* control before all later-added listeners.
*
* @return true if message is handled, false if it was not
*/
boolean handleMessage(in nsISOAPMessage aMessage, in boolean aCapture);
};

View File

@@ -0,0 +1,52 @@
#
# The contents of this file are subject to the Mozilla Public
# License Version 1.1 (the "License"); you may not use this file
# except in compliance with the License. You may obtain a copy of
# the License at http://www.mozilla.org/MPL/
#
# Software distributed under the License is distributed on an "AS
# IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
# implied. See the License for the specific language governing
# rights and limitations under the License.
#
# The Original Code is mozilla.org code.
#
# The Initial Developer of the Original Code is Netscape
# Communications Corporation. Portions created by Netscape are
# Copyright (C) 1998 Netscape Communications Corporation. All
# Rights Reserved.
#
# Contributor(s):
#
DEPTH = ../../../..
topsrcdir = ../../../..
srcdir = .
VPATH = .
include $(DEPTH)/config/autoconf.mk
MODULE = xmlextras
LIBRARY_NAME = xmlextrassoap_s
REQUIRES = xpcom string caps dom js widget layout xpconnect necko
CPPSRCS = \
nsSOAPCall.cpp \
nsDefaultSOAPEncoder.cpp\
nsSOAPFault.cpp \
nsSOAPHeaderBlock.cpp \
nsSOAPJSValue.cpp \
nsSOAPMessage.cpp \
nsSOAPParameter.cpp \
nsSOAPResponse.cpp \
nsSOAPStruct.cpp \
nsSOAPUtils.cpp \
nsSOAPEncodingRegistry.cpp \
$(NULL)
# we don't want the shared lib, but we want to force the creation of a
# static lib.
override NO_SHARED_LIB=1
override NO_STATIC_LIB=
include $(topsrcdir)/config/rules.mk

View File

@@ -0,0 +1,52 @@
#
# The contents of this file are subject to the Mozilla Public
# License Version 1.1 (the "License"); you may not use this file
# except in compliance with the License. You may obtain a copy of
# the License at http://www.mozilla.org/MPL/
#
# Software distributed under the License is distributed on an "AS
# IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
# implied. See the License for the specific language governing
# rights and limitations under the License.
#
# The Original Code is mozilla.org code.
#
# The Initial Developer of the Original Code is Netscape
# Communications Corporation. Portions created by Netscape are
# Copyright (C) 1998 Netscape Communications Corporation. All
# Rights Reserved.
#
# Contributor(s):
#
DEPTH = ../../../..
topsrcdir = @top_srcdir@
srcdir = @srcdir@
VPATH = @srcdir@
include $(DEPTH)/config/autoconf.mk
MODULE = xmlextras
LIBRARY_NAME = xmlextrassoap_s
REQUIRES = xpcom string caps dom js widget xpconnect necko schema
CPPSRCS = \
nsDefaultSOAPEncoder.cpp\
nsHTTPSOAPTransport.cpp \
nsSOAPCall.cpp \
nsSOAPEncoding.cpp \
nsSOAPFault.cpp \
nsSOAPHeaderBlock.cpp \
nsSOAPMessage.cpp \
nsSOAPParameter.cpp \
nsSOAPResponse.cpp \
nsSOAPUtils.cpp \
$(NULL)
# we don't want the shared lib, but we want to force the creation of a
# static lib.
FORCE_STATIC_LIB = 1
#override NO_SHARED_LIB=1
#override NO_STATIC_LIB=
include $(topsrcdir)/config/rules.mk

View File

@@ -0,0 +1,64 @@
#!nmake
#
# The contents of this file are subject to the Netscape 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/NPL/
#
# Software distributed under the License is distributed on an "AS
# IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
# implied. See the License for the specific language governing
# rights and limitations under the License.
#
# The Original Code is mozilla.org code.
#
# The Initial Developer of the Original Code is Netscape
# Communications Corporation. Portions created by Netscape are
# Copyright (C) 1998 Netscape Communications Corporation. All
# Rights Reserved.
#
# Contributor(s):
DEPTH=..\..\..\..
LIBRARY_NAME=xmlextrassoap_s
MODULE=xmlextras
REQUIRES = \
xpcom \
string \
caps \
dom \
js \
widget \
xpconnect \
necko
DEFINES=-D_IMPL_NS_HTML -DWIN32_LEAN_AND_MEAN
OBJS= \
.\$(OBJDIR)\nsDefaultSOAPEncoder.obj \
.\$(OBJDIR)\nsHTTPSOAPTransport.obj \
.\$(OBJDIR)\nsSOAPCall.obj \
.\$(OBJDIR)\nsSOAPEncoding.obj \
.\$(OBJDIR)\nsSOAPFault.obj \
.\$(OBJDIR)\nsSOAPHeaderBlock.obj \
.\$(OBJDIR)\nsSOAPMessage.obj \
.\$(OBJDIR)\nsSOAPParameter.obj \
.\$(OBJDIR)\nsSOAPResponse.obj \
# .\$(OBJDIR)\nsSOAPStruct.obj \
.\$(OBJDIR)\nsSOAPUtils.obj \
$(NULL)
LCFLAGS = \
$(LCFLAGS) \
$(DEFINES) \
$(NULL)
include <$(DEPTH)\config\rules.mak>
libs:: $(LIBRARY)
$(MAKE_INSTALL) $(LIBRARY) $(DIST)\lib
clobber::
rm -f $(DIST)\lib\$(LIBRARY_NAME).lib

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,34 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Netscape 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/NPL/
*
* Software distributed under the License is distributed on an "AS
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
* implied. See the License for the specific language governing
* rights and limitations under the License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All
* Rights Reserved.
*
* Contributor(s):
*/
#ifndef nsDefaultSOAPEncoder_h__
#define nsDefaultSOAPEncoder_h__
#include "nsSOAPEncoding.h"
class nsDefaultSOAPEncoder : public nsSOAPEncoding
{
public:
nsDefaultSOAPEncoder();
};
#endif

View File

@@ -0,0 +1,196 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Netscape 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/NPL/
*
* Software distributed under the License is distributed on an "AS
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
* implied. See the License for the specific language governing
* rights and limitations under the License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All
* Rights Reserved.
*
* Contributor(s):
*/
#include "nsHTTPSOAPTransport.h"
#include "nsIComponentManager.h"
#include "nsIDOMDocument.h"
#include "nsString.h"
#include "nsSOAPUtils.h"
#include "nsSOAPCall.h"
#include "nsSOAPResponse.h"
#include "nsIDOMEventTarget.h"
nsHTTPSOAPTransport::nsHTTPSOAPTransport()
{
NS_INIT_ISUPPORTS();
}
nsHTTPSOAPTransport::~nsHTTPSOAPTransport()
{
}
NS_IMPL_ISUPPORTS1_CI(nsHTTPSOAPTransport, nsISOAPTransport)
/* void syncCall (in nsISOAPCall aCall, in nsISOAPResponse aResponse); */
NS_IMETHODIMP nsHTTPSOAPTransport::SyncCall(nsISOAPCall *aCall, nsISOAPResponse *aResponse)
{
NS_ENSURE_ARG(aCall);
nsresult rv;
nsCOMPtr<nsIXMLHttpRequest> request;
request = do_CreateInstance(NS_XMLHTTPREQUEST_CONTRACTID, &rv);
if (NS_FAILED(rv)) return rv;
nsAutoString action;
rv = aCall->GetActionURI(action);
if (NS_FAILED(rv)) return rv;
if (!AStringIsNull(action)) {
rv = request->SetRequestHeader("SOAPAction", NS_ConvertUCS2toUTF8(action).get());
if (NS_FAILED(rv)) return rv;
}
nsAutoString uri;
rv = aCall->GetTransportURI(uri);
if (NS_FAILED(rv)) return rv;
if (!AStringIsNull(uri)) return NS_ERROR_NOT_INITIALIZED;
nsCOMPtr<nsIDOMDocument> messageDocument;
rv = aCall->GetMessage(getter_AddRefs(messageDocument));
if (NS_FAILED(rv)) return rv;
if (!messageDocument) return NS_ERROR_NOT_INITIALIZED;
rv = request->OpenRequest("POST", NS_ConvertUCS2toUTF8(uri).get(), PR_FALSE, nsnull, nsnull);
if (NS_FAILED(rv)) return rv;
rv = request->Send(messageDocument);
if (NS_FAILED(rv)) return rv;
request->GetStatus(&rv);
if (NS_FAILED(rv)) return rv;
if (aResponse) {
nsCOMPtr<nsIDOMDocument> response;
rv = request->GetResponseXML(getter_AddRefs(response));
if (NS_FAILED(rv)) return rv;
rv = aResponse->SetMessage(response);
if (NS_FAILED(rv)) return rv;
}
return NS_OK;
}
class nsHTTPSOAPTransportCompletion : public nsIDOMEventListener
{
public:
nsHTTPSOAPTransportCompletion();
virtual ~nsHTTPSOAPTransportCompletion();
NS_DECL_ISUPPORTS
// nsIDOMEventListener
NS_IMETHOD HandleEvent(nsIDOMEvent* aEvent);
protected:
nsCOMPtr<nsISOAPCall> mCall;
nsCOMPtr<nsISOAPResponse> mResponse;
nsCOMPtr<nsIXMLHttpRequest> mRequest;
nsCOMPtr<nsISOAPResponseListener> mListener;
};
NS_IMPL_ISUPPORTS1(nsHTTPSOAPTransportCompletion, nsIDOMEventListener)
nsHTTPSOAPTransportCompletion::nsHTTPSOAPTransportCompletion()
{
NS_INIT_ISUPPORTS();
}
nsHTTPSOAPTransportCompletion::~nsHTTPSOAPTransportCompletion()
{
}
NS_IMETHODIMP
nsHTTPSOAPTransportCompletion::HandleEvent(nsIDOMEvent* aEvent)
{
nsresult rv;
mRequest->GetStatus(&rv);
if (NS_SUCCEEDED(rv)) {
nsCOMPtr<nsIDOMDocument> document;
rv = mRequest->GetResponseXML(getter_AddRefs(document));
if (NS_SUCCEEDED(rv)) {
rv = mResponse->SetMessage(document);
}
}
PRBool c; // In other transports, this may signal to stop returning if multiple returns
mListener->HandleResponse(mResponse, mCall, (PRInt32)rv, PR_TRUE, &c);
return NS_OK;
}
/* void asyncCall (in nsISOAPCall aCall, in nsISOAPResponseListener aListener, in nsISOAPResponse aResponse); */
NS_IMETHODIMP nsHTTPSOAPTransport::AsyncCall(nsISOAPCall *aCall, nsISOAPResponseListener *aListener, nsISOAPResponse *aResponse)
{
NS_ENSURE_ARG(aCall);
nsresult rv;
nsCOMPtr<nsIXMLHttpRequest> request;
nsCOMPtr<nsIDOMEventTarget> eventTarget = do_QueryInterface(request, &rv);
if (NS_FAILED(rv)) return rv;
request = do_CreateInstance(NS_XMLHTTPREQUEST_CONTRACTID, &rv);
if (NS_FAILED(rv)) return rv;
nsAutoString action;
rv = aCall->GetActionURI(action);
if (NS_FAILED(rv)) return rv;
if (!AStringIsNull(action)) {
rv = request->SetRequestHeader("SOAPAction", NS_ConvertUCS2toUTF8(action).get());
if (NS_FAILED(rv)) return rv;
}
nsCOMPtr<nsIDOMEventListener> listener = new nsHTTPSOAPTransportCompletion();
if (!listener) return NS_ERROR_OUT_OF_MEMORY;
nsAutoString uri;
rv = aCall->GetTransportURI(uri);
if (NS_FAILED(rv)) return rv;
if (!AStringIsNull(uri)) return NS_ERROR_NOT_INITIALIZED;
nsCOMPtr<nsIDOMDocument> messageDocument;
rv = aCall->GetMessage(getter_AddRefs(messageDocument));
if (NS_FAILED(rv)) return rv;
if (!messageDocument) return NS_ERROR_NOT_INITIALIZED;
rv = request->OpenRequest("POST", NS_ConvertUCS2toUTF8(uri).get(), PR_TRUE, nsnull, nsnull);
if (NS_FAILED(rv)) return rv;
rv = request->Send(messageDocument);
if (NS_FAILED(rv)) return rv;
eventTarget->AddEventListener(NS_LITERAL_STRING("load"), listener, PR_FALSE);
eventTarget->AddEventListener(NS_LITERAL_STRING("error"), listener, PR_FALSE);
rv = request->Send(messageDocument);
if (NS_FAILED(rv)) return rv;
return NS_OK;
}
/* void addListener (in nsISOAPTransportListener aListener, in boolean aCapture); */
NS_IMETHODIMP nsHTTPSOAPTransport::AddListener(nsISOAPTransportListener *aListener, PRBool aCapture)
{
return NS_ERROR_NOT_IMPLEMENTED;
}
/* void removeListener (in nsISOAPTransportListener aListener, in boolean aCapture); */
NS_IMETHODIMP nsHTTPSOAPTransport::RemoveListener(nsISOAPTransportListener *aListener, PRBool aCapture)
{
return NS_ERROR_NOT_IMPLEMENTED;
}

View File

@@ -0,0 +1,50 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Netscape 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/NPL/
*
* Software distributed under the License is distributed on an "AS
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
* implied. See the License for the specific language governing
* rights and limitations under the License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All
* Rights Reserved.
*
* Contributor(s):
*/
#ifndef nsHTTPSOAPTransport_h__
#define nsHTTPSOAPTransport_h__
#include "nsISOAPTransport.h"
#include "nsIXMLHttpRequest.h"
#include "nsIDOMEventListener.h"
#include "nsISOAPTransportListener.h"
#include "nsCOMPtr.h"
class nsHTTPSOAPTransport : public nsISOAPTransport
{
public:
nsHTTPSOAPTransport();
virtual ~nsHTTPSOAPTransport();
NS_DECL_ISUPPORTS
// nsISOAPTransport
NS_DECL_NSISOAPTRANSPORT
};
#define NS_HTTPSOAPTRANSPORT_CID \
{ /* d852ade0-5823-11d4-9a62-00104bdf5339 */ \
0xd852ade0, 0x5823, 0x11d4, \
{0x9a, 0x62, 0x00, 0x10, 0x4b, 0xdf, 0x53, 0x39} }
#define NS_HTTPSOAPTRANSPORT_CONTRACTID NS_SOAPTRANSPORT_CONTRACTID_PREFIX "http"
#endif

View File

@@ -0,0 +1,187 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Netscape 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/NPL/
*
* Software distributed under the License is distributed on an "AS
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
* implied. See the License for the specific language governing
* rights and limitations under the License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All
* Rights Reserved.
*
* Contributor(s):
*/
#include "nsSOAPCall.h"
#include "nsSOAPResponse.h"
#include "nsSOAPUtils.h"
#include "nsISOAPTransport.h"
#include "nsIServiceManager.h"
#include "nsIComponentManager.h"
#include "nsIURI.h"
#include "nsNetUtil.h"
/////////////////////////////////////////////
//
//
/////////////////////////////////////////////
nsSOAPCall::nsSOAPCall()
{
}
nsSOAPCall::~nsSOAPCall()
{
}
NS_IMPL_CI_INTERFACE_GETTER2(nsSOAPCall, nsISOAPMessage, nsISOAPCall)
NS_IMPL_ADDREF_INHERITED(nsSOAPCall, nsSOAPMessage)
NS_IMPL_RELEASE_INHERITED(nsSOAPCall, nsSOAPMessage)
NS_INTERFACE_MAP_BEGIN(nsSOAPCall)
NS_INTERFACE_MAP_ENTRY(nsISOAPCall)
NS_IMPL_QUERY_CLASSINFO(nsSOAPCall)
NS_INTERFACE_MAP_END_INHERITING(nsSOAPMessage)
/* attribute DOMString transportURI; */
NS_IMETHODIMP nsSOAPCall::GetTransportURI(nsAWritableString & aTransportURI)
{
NS_ENSURE_ARG_POINTER(&aTransportURI);
aTransportURI.Assign(mTransportURI);
return NS_OK;
}
NS_IMETHODIMP nsSOAPCall::SetTransportURI(const nsAReadableString & aTransportURI)
{
mTransportURI.Assign(aTransportURI);
return NS_OK;
}
nsresult
nsSOAPCall::GetTransport(nsISOAPTransport** aTransport)
{
NS_ENSURE_ARG_POINTER(aTransport);
nsresult rv;
nsCOMPtr<nsIURI> uri;
nsXPIDLCString protocol;
nsCString transportURI(ToNewCString(mTransportURI));
rv = NS_NewURI(getter_AddRefs(uri), transportURI.get());
if (NS_FAILED(rv)) return rv;
uri->GetScheme(getter_Copies(protocol));
nsCAutoString transportContractid;
transportContractid.Assign(NS_SOAPTRANSPORT_CONTRACTID_PREFIX);
transportContractid.Append(protocol);
nsCOMPtr<nsISOAPTransport> transport = do_GetService(transportContractid.get(), &rv);
if (NS_FAILED(rv)) return rv;
*aTransport = transport.get();
NS_ADDREF(*aTransport);
return NS_OK;
}
/* nsISOAPResponse invoke (); */
NS_IMETHODIMP nsSOAPCall::Invoke(nsISOAPResponse **_retval)
{
NS_ENSURE_ARG_POINTER(_retval);
nsresult rv;
nsCOMPtr<nsISOAPTransport> transport;
if (mTransportURI.Length() == 0) {
return NS_ERROR_NOT_INITIALIZED;
}
rv = GetTransport(getter_AddRefs(transport));
if (NS_FAILED(rv)) return rv;
nsCOMPtr<nsISOAPResponse> response;
response = new nsSOAPResponse();
if (!response) return NS_ERROR_OUT_OF_MEMORY;
rv = response->SetEncoding(mEncoding);
if (NS_FAILED(rv)) return rv;
rv = transport->SyncCall(this, response);
if (NS_FAILED(rv)) return rv;
return response->QueryInterface(NS_GET_IID(nsISOAPResponse), (void**)_retval);
}
/* void asyncInvoke (in nsISOAPResponseListener listener); */
NS_IMETHODIMP nsSOAPCall::AsyncInvoke(nsISOAPResponseListener *listener)
{
nsresult rv;
nsCOMPtr<nsISOAPTransport> transport;
if (mTransportURI.Length() == 0) {
return NS_ERROR_NOT_INITIALIZED;
}
rv = GetTransport(getter_AddRefs(transport));
if (NS_FAILED(rv)) return rv;
nsCOMPtr<nsISOAPResponse> response;
response = new nsSOAPResponse();
if (!response) return NS_ERROR_OUT_OF_MEMORY;
rv = response->SetEncoding(mEncoding);
if (NS_FAILED(rv)) return rv;
rv = transport->AsyncCall(this, listener, response);
return rv;
}
static const char* kAllAccess = "AllAccess";
/* string canCreateWrapper (in nsIIDPtr iid); */
NS_IMETHODIMP
nsSOAPCall::CanCreateWrapper(const nsIID * iid, char **_retval)
{
if (iid->Equals(NS_GET_IID(nsISOAPCall))) {
*_retval = nsCRT::strdup(kAllAccess);
}
return NS_OK;
}
/* string canCallMethod (in nsIIDPtr iid, in wstring methodName); */
NS_IMETHODIMP
nsSOAPCall::CanCallMethod(const nsIID * iid, const PRUnichar *methodName, char **_retval)
{
if (iid->Equals(NS_GET_IID(nsISOAPCall))) {
*_retval = nsCRT::strdup(kAllAccess);
}
return NS_OK;
}
/* string canGetProperty (in nsIIDPtr iid, in wstring propertyName); */
NS_IMETHODIMP
nsSOAPCall::CanGetProperty(const nsIID * iid, const PRUnichar *propertyName, char **_retval)
{
if (iid->Equals(NS_GET_IID(nsISOAPCall))) {
*_retval = nsCRT::strdup(kAllAccess);
}
return NS_OK;
}
/* string canSetProperty (in nsIIDPtr iid, in wstring propertyName); */
NS_IMETHODIMP
nsSOAPCall::CanSetProperty(const nsIID * iid, const PRUnichar *propertyName, char **_retval)
{
if (iid->Equals(NS_GET_IID(nsISOAPCall))) {
*_retval = nsCRT::strdup(kAllAccess);
}
return NS_OK;
}

View File

@@ -0,0 +1,58 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Netscape 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/NPL/
*
* Software distributed under the License is distributed on an "AS
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
* implied. See the License for the specific language governing
* rights and limitations under the License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All
* Rights Reserved.
*
* Contributor(s):
*/
#ifndef nsSOAPCall_h__
#define nsSOAPCall_h__
#include "nsString.h"
#include "nsSOAPMessage.h"
#include "nsISOAPCall.h"
#include "nsISecurityCheckedComponent.h"
#include "nsISOAPTransport.h"
#include "nsISOAPResponseListener.h"
#include "nsCOMPtr.h"
class nsSOAPCall : public nsSOAPMessage,
public nsISOAPCall
{
public:
nsSOAPCall();
virtual ~nsSOAPCall();
NS_DECL_ISUPPORTS
// nsISOAPCall
NS_FORWARD_NSISOAPMESSAGE(nsSOAPMessage::)
// nsISOAPCall
NS_DECL_NSISOAPCALL
// nsISecurityCheckedComponent
NS_DECL_NSISECURITYCHECKEDCOMPONENT
protected:
nsString mTransportURI;
nsresult GetTransport(nsISOAPTransport** aTransport);
};
#endif

View File

@@ -0,0 +1,405 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Netscape 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/NPL/
*
* Software distributed under the License is distributed on an "AS
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
* implied. See the License for the specific language governing
* rights and limitations under the License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All
* Rights Reserved.
*
* Contributor(s):
*/
#include "nsString.h"
#include "nsISOAPParameter.h"
#include "nsSOAPMessage.h"
#include "nsISOAPEncoder.h"
#include "nsISOAPDecoder.h"
#include "nsSOAPEncoding.h"
#include "nsSOAPUtils.h"
#include "nsIServiceManager.h"
#include "nsIComponentManager.h"
#include "nsIDOMNodeList.h"
#include "nsISchema.h"
#include "nsISchemaLoader.h"
#include "nsSOAPUtils.h"
// First comes the registry which shares between associated encodings but is never seen by xpconnect.
NS_IMPL_ISUPPORTS1(nsSOAPEncodingRegistry,nsISOAPEncoding)
nsSOAPEncodingRegistry::nsSOAPEncodingRegistry(nsISOAPEncoding* aEncoding): mEncodings(new nsSupportsHashtable)
{
NS_INIT_ISUPPORTS();
nsAutoString style;
aEncoding->GetStyleURI(style);
nsStringKey styleKey(style);
mEncodings->Put(&styleKey, aEncoding);
/* member initializers and constructor code */
}
nsSOAPEncodingRegistry::~nsSOAPEncodingRegistry()
{
/* destructor code */
delete mEncodings;
}
nsresult nsSOAPEncodingRegistry::GetStyle(const nsAString& aStyleURI, PRBool aCreateIf, nsISOAPEncoding* * aEncoding)
{
NS_SOAP_ENSURE_ARG_STRING(aStyleURI);
NS_ENSURE_ARG_POINTER(aEncoding);
nsStringKey styleKey(aStyleURI);
*aEncoding = (nsISOAPEncoding*)mEncodings->Get(&styleKey);
if (!*aEncoding)
{
nsCOMPtr<nsISOAPEncoding> defaultEncoding;
nsCAutoString encodingContractid;
encodingContractid.Assign(NS_SOAPENCODING_CONTRACTID_PREFIX);
encodingContractid.Append(NS_ConvertUCS2toUTF8(aStyleURI));
defaultEncoding = do_GetService(encodingContractid.get());
if (defaultEncoding || aCreateIf) {
*aEncoding = new nsSOAPEncoding(aStyleURI, this, defaultEncoding);
mEncodings->Put(&styleKey, *aEncoding);
}
}
return NS_OK;
}
nsresult nsSOAPEncodingRegistry::SetSchemaCollection(nsISchemaCollection* aSchemaCollection)
{
NS_ENSURE_ARG(aSchemaCollection);
mSchemaCollection = aSchemaCollection;
return NS_OK;
}
nsresult nsSOAPEncodingRegistry::GetSchemaCollection(nsISchemaCollection** aSchemaCollection)
{
NS_ENSURE_ARG_POINTER(aSchemaCollection);
if (!mSchemaCollection) {
nsresult rv;
nsCOMPtr<nsISchemaLoader>loader = do_CreateInstance(NS_SCHEMALOADER_CONTRACTID, &rv);
if (NS_FAILED(rv)) return rv;
mSchemaCollection = do_QueryInterface(loader);
if (!mSchemaCollection) return NS_ERROR_FAILURE;
}
*aSchemaCollection = mSchemaCollection;
NS_ADDREF(*aSchemaCollection);
return NS_OK;
}
/* readonly attribute AString styleURI; */
NS_IMETHODIMP nsSOAPEncodingRegistry::GetStyleURI(nsAString & aStyleURI)
{
return NS_ERROR_NOT_IMPLEMENTED;
}
/* nsISOAPEncoder setEncoder (in AString aSchemaNamespaceURI, in AString aSchemaType, in nsISOAPEncoder aEncoder); */
NS_IMETHODIMP nsSOAPEncodingRegistry::SetEncoder(const nsAString & aSchemaNamespaceURI, const nsAString & aSchemaType, nsISOAPEncoder *aEncoder)
{
return NS_ERROR_NOT_IMPLEMENTED;
}
/* nsISOAPEncoder getEncoder (in AString aSchemaNamespaceURI, in AString aSchemaType); */
NS_IMETHODIMP nsSOAPEncodingRegistry::GetEncoder(const nsAString & aSchemaNamespaceURI, const nsAString & aSchemaType, nsISOAPEncoder **_retval)
{
return NS_ERROR_NOT_IMPLEMENTED;
}
/* nsISOAPDecoder setDecoder (in AString aSchemaNamespaceURI, in AString aSchemaType, in nsISOAPDecoder aDecoder); */
NS_IMETHODIMP nsSOAPEncodingRegistry::SetDecoder(const nsAString & aSchemaNamespaceURI, const nsAString & aSchemaType, nsISOAPDecoder *aDecoder)
{
return NS_ERROR_NOT_IMPLEMENTED;
}
/* nsISOAPDecoder getDecoder (in AString aSchemaNamespaceURI, in AString aSchemaType); */
NS_IMETHODIMP nsSOAPEncodingRegistry::GetDecoder(const nsAString & aSchemaNamespaceURI, const nsAString & aSchemaType, nsISOAPDecoder **_retval)
{
return NS_ERROR_NOT_IMPLEMENTED;
}
/* attribute nsISOAPEncoder defaultEncoder; */
NS_IMETHODIMP nsSOAPEncodingRegistry::GetDefaultEncoder(nsISOAPEncoder * *aDefaultEncoder)
{
return NS_ERROR_NOT_IMPLEMENTED;
}
NS_IMETHODIMP nsSOAPEncodingRegistry::SetDefaultEncoder(nsISOAPEncoder * aDefaultEncoder)
{
return NS_ERROR_NOT_IMPLEMENTED;
}
/* attribute nsISOAPDecoder defaultDecoder; */
NS_IMETHODIMP nsSOAPEncodingRegistry::GetDefaultDecoder(nsISOAPDecoder * *aDefaultDecoder)
{
return NS_ERROR_NOT_IMPLEMENTED;
}
NS_IMETHODIMP nsSOAPEncodingRegistry::SetDefaultDecoder(nsISOAPDecoder * aDefaultDecoder)
{
return NS_ERROR_NOT_IMPLEMENTED;
}
/* nsIDOMElement encode (in nsIVariant aSource, in AString aNamespaceURI, in AString aName, in nsISchemaType aSchemaType, in nsISOAPAttachments aAttachments, in nsIDOMElement aDestination); */
NS_IMETHODIMP nsSOAPEncodingRegistry::Encode(nsIVariant *aSource, const nsAString & aNamespaceURI, const nsAString & aName, nsISchemaType *aSchemaType, nsISOAPAttachments *aAttachments, nsIDOMElement *aDestination, nsIDOMElement **_retval)
{
return NS_ERROR_NOT_IMPLEMENTED;
}
/* nsIVariant decode (in nsIDOMElement aSource, in nsISchemaType aSchemaType, in nsISOAPAttachments aAttachments); */
NS_IMETHODIMP nsSOAPEncodingRegistry::Decode(nsIDOMElement *aSource, nsISchemaType *aSchemaType, nsISOAPAttachments *aAttachments, nsIVariant **_retval)
{
return NS_ERROR_NOT_IMPLEMENTED;
}
// Second, we create the encodings themselves.
NS_IMPL_ISUPPORTS2(nsSOAPEncoding, nsISOAPEncoding, nsISecurityCheckedComponent)
nsSOAPEncoding::nsSOAPEncoding(): mEncoders(new nsSupportsHashtable),
mDecoders(new nsSupportsHashtable)
{
NS_INIT_ISUPPORTS();
/* member initializers and constructor code */
mStyleURI.Assign(nsSOAPUtils::kSOAPEncodingURI);
mDefaultEncoding = do_GetService(NS_DEFAULTSOAPENCODER_CONTRACTID);
mRegistry = new nsSOAPEncodingRegistry(this);
}
nsSOAPEncoding::nsSOAPEncoding(const nsAString& aStyleURI, nsSOAPEncodingRegistry* aRegistry, nsISOAPEncoding* aDefaultEncoding)
: mEncoders(new nsSupportsHashtable), mDecoders(new nsSupportsHashtable)
{
NS_INIT_ISUPPORTS();
/* member initializers and constructor code */
mStyleURI.Assign(aStyleURI);
mRegistry = aRegistry;
mDefaultEncoding = aDefaultEncoding;
}
nsSOAPEncoding::~nsSOAPEncoding()
{
/* destructor code */
delete mEncoders;
delete mDecoders;
}
nsresult nsSOAPEncoding::SetSchemaCollection(nsISchemaCollection* aSchemaCollection)
{
NS_ENSURE_ARG(aSchemaCollection);
return mRegistry->SetSchemaCollection(aSchemaCollection);
}
nsresult nsSOAPEncoding::GetSchemaCollection(nsISchemaCollection** aSchemaCollection)
{
NS_ENSURE_ARG_POINTER(aSchemaCollection);
return mRegistry->GetSchemaCollection(aSchemaCollection);
}
/* readonly attribute AString styleURI; */
NS_IMETHODIMP nsSOAPEncoding::GetStyleURI(nsAString & aStyleURI)
{
NS_SOAP_ENSURE_ARG_STRING(aStyleURI);
aStyleURI.Assign(mStyleURI);
return NS_OK;
}
/* nsISOAPEncoding getStyle (in AString aStyleURI, in boolean aCreateIf); */
NS_IMETHODIMP nsSOAPEncoding::GetStyle(const nsAString & aStyleURI, PRBool aCreateIf, nsISOAPEncoding **_retval)
{
NS_SOAP_ENSURE_ARG_STRING(aStyleURI);
NS_ENSURE_ARG_POINTER(_retval);
return mRegistry->GetStyle(aStyleURI, aCreateIf, _retval);
}
/* nsISOAPEncoder setEncoder (in AString aSchemaNamespaceURI, in AString aSchemaType, in nsISOAPEncoder aEncoder); */
NS_IMETHODIMP nsSOAPEncoding::SetEncoder(const nsAString & aSchemaNamespaceURI, const nsAString & aSchemaType, nsISOAPEncoder *aEncoder)
{
NS_SOAP_ENSURE_ARG_STRING(aSchemaNamespaceURI);
NS_SOAP_ENSURE_ARG_STRING(aSchemaType);
NS_ENSURE_ARG(aEncoder);
nsAutoString name(aSchemaNamespaceURI);
name.Append(nsSOAPUtils::kEncodingSeparator);
name.Append(aSchemaType);
nsStringKey nameKey(name);
if (aEncoder) {
mEncoders->Put(&nameKey, aEncoder, nsnull);
}
else {
mEncoders->Remove(&nameKey, nsnull);
}
return NS_OK;
}
/* nsISOAPEncoder getEncoder (in AString aSchemaNamespaceURI, in AString aSchemaType); */
NS_IMETHODIMP nsSOAPEncoding::GetEncoder(const nsAString & aSchemaNamespaceURI, const nsAString & aSchemaType, nsISOAPEncoder **_retval)
{
NS_SOAP_ENSURE_ARG_STRING(aSchemaNamespaceURI);
NS_SOAP_ENSURE_ARG_STRING(aSchemaType);
NS_ENSURE_ARG_POINTER(_retval);
nsAutoString name(aSchemaNamespaceURI);
name.Append(nsSOAPUtils::kEncodingSeparator);
name.Append(aSchemaType);
nsStringKey nameKey(name);
*_retval = (nsISOAPEncoder*)mEncoders->Get(&nameKey);
if (*_retval == nsnull && mDefaultEncoding != nsnull) {
return mDefaultEncoding->GetEncoder(aSchemaNamespaceURI, aSchemaType, _retval);
}
return NS_OK;
}
/* nsISOAPDecoder setDecoder (in AString aSchemaNamespaceURI, in AString aSchemaType, in nsISOAPDecoder aDecoder); */
NS_IMETHODIMP nsSOAPEncoding::SetDecoder(const nsAString & aSchemaNamespaceURI, const nsAString & aSchemaType, nsISOAPDecoder *aDecoder)
{
NS_SOAP_ENSURE_ARG_STRING(aSchemaNamespaceURI);
NS_SOAP_ENSURE_ARG_STRING(aSchemaType);
nsAutoString name(aSchemaNamespaceURI);
name.Append(nsSOAPUtils::kEncodingSeparator);
name.Append(aSchemaType);
nsStringKey nameKey(name);
if (aDecoder) {
mDecoders->Put(&nameKey, aDecoder, nsnull);
}
else {
mDecoders->Remove(&nameKey, nsnull);
}
return NS_OK;
}
/* nsISOAPDecoder getDecoder (in AString aSchemaNamespaceURI, in AString aSchemaType); */
NS_IMETHODIMP nsSOAPEncoding::GetDecoder(const nsAString & aSchemaNamespaceURI, const nsAString & aSchemaType, nsISOAPDecoder **_retval)
{
NS_SOAP_ENSURE_ARG_STRING(aSchemaNamespaceURI);
NS_SOAP_ENSURE_ARG_STRING(aSchemaType);
NS_ENSURE_ARG_POINTER(_retval);
nsAutoString name(aSchemaNamespaceURI);
name.Append(nsSOAPUtils::kEncodingSeparator);
name.Append(aSchemaType);
nsStringKey nameKey(name);
*_retval = (nsISOAPDecoder*)mDecoders->Get(&nameKey);
if (*_retval == nsnull && mDefaultEncoding != nsnull) {
return mDefaultEncoding->GetDecoder(aSchemaNamespaceURI, aSchemaType, _retval);
}
return NS_OK;
}
/* nsIDOMElement encode (in nsIVariant aSource, in AString aNamespaceURI, in AString aName, in nsISchemaType aSchemaType, in nsISOAPAttachments aAttachments, in nsIDOMElement aDestination); */
NS_IMETHODIMP nsSOAPEncoding::Encode(nsIVariant *aSource, const nsAString & aNamespaceURI, const nsAString & aName, nsISchemaType *aSchemaType, nsISOAPAttachments *aAttachments, nsIDOMElement *aDestination, nsIDOMElement **_retval)
{
NS_ENSURE_ARG(aSource);
NS_ENSURE_ARG_POINTER(_retval);
nsCOMPtr<nsISOAPEncoder> encoder;
nsresult rv = GetDefaultEncoder(getter_AddRefs(encoder));
if (NS_FAILED(rv)) return rv;
if (encoder) {
return encoder->Encode(this, aSource, aNamespaceURI, aName, aSchemaType, aAttachments, aDestination,
_retval);
}
*_retval = nsnull;
return NS_ERROR_NOT_IMPLEMENTED;
}
/* nsIVariant decode (in nsIDOMElement aSource, in nsISchemaType aSchemaType, in nsISOAPAttachments aAttachments); */
NS_IMETHODIMP nsSOAPEncoding::Decode(nsIDOMElement *aSource, nsISchemaType *aSchemaType, nsISOAPAttachments *aAttachments, nsIVariant **_retval)
{
NS_ENSURE_ARG(aSource);
NS_ENSURE_ARG_POINTER(_retval);
nsCOMPtr<nsISOAPDecoder> decoder;
nsresult rv = GetDefaultDecoder(getter_AddRefs(decoder));
if (NS_FAILED(rv)) return rv;
if (decoder) {
return decoder->Decode(this, aSource, aSchemaType, aAttachments, _retval);
}
*_retval = nsnull;
return NS_ERROR_NOT_IMPLEMENTED;
}
/* attribute nsISOAPEncoder defaultEncoder; */
NS_IMETHODIMP nsSOAPEncoding::GetDefaultEncoder(nsISOAPEncoder * *aDefaultEncoder)
{
NS_ENSURE_ARG_POINTER(aDefaultEncoder);
if (mDefaultEncoding && !mDefaultEncoder) {
return mDefaultEncoding->GetDefaultEncoder(aDefaultEncoder);
}
*aDefaultEncoder = mDefaultEncoder;
NS_IF_ADDREF(*aDefaultEncoder);
return NS_OK;
}
NS_IMETHODIMP nsSOAPEncoding::SetDefaultEncoder(nsISOAPEncoder * aDefaultEncoder)
{
mDefaultEncoder = aDefaultEncoder;
return NS_OK;
}
/* attribute nsISOAPDecoder defaultDecoder; */
NS_IMETHODIMP nsSOAPEncoding::GetDefaultDecoder(nsISOAPDecoder * *aDefaultDecoder)
{
NS_ENSURE_ARG_POINTER(aDefaultDecoder);
if (mDefaultEncoding && !mDefaultDecoder) {
return mDefaultEncoding->GetDefaultDecoder(aDefaultDecoder);
}
*aDefaultDecoder = mDefaultDecoder;
NS_IF_ADDREF(*aDefaultDecoder);
return NS_OK;
return NS_ERROR_NOT_IMPLEMENTED;
}
NS_IMETHODIMP nsSOAPEncoding::SetDefaultDecoder(nsISOAPDecoder * aDefaultDecoder)
{
mDefaultDecoder = aDefaultDecoder;
return NS_OK;
}
static const char* kAllAccess = "AllAccess";
/* string canCreateWrapper (in nsIIDPtr iid); */
NS_IMETHODIMP
nsSOAPEncoding::CanCreateWrapper(const nsIID * iid, char **_retval)
{
if (iid->Equals(NS_GET_IID(nsISOAPEncoding))) {
*_retval = nsCRT::strdup(kAllAccess);
}
return NS_OK;
}
/* string canCallMethod (in nsIIDPtr iid, in wstring methodName); */
NS_IMETHODIMP
nsSOAPEncoding::CanCallMethod(const nsIID * iid, const PRUnichar *methodName, char **_retval)
{
if (iid->Equals(NS_GET_IID(nsISOAPEncoding))) {
*_retval = nsCRT::strdup(kAllAccess);
}
return NS_OK;
}
/* string canGetProperty (in nsIIDPtr iid, in wstring propertyName); */
NS_IMETHODIMP
nsSOAPEncoding::CanGetProperty(const nsIID * iid, const PRUnichar *propertyName, char **_retval)
{
if (iid->Equals(NS_GET_IID(nsISOAPEncoding))) {
*_retval = nsCRT::strdup(kAllAccess);
}
return NS_OK;
}
/* string canSetProperty (in nsIIDPtr iid, in wstring propertyName); */
NS_IMETHODIMP
nsSOAPEncoding::CanSetProperty(const nsIID * iid, const PRUnichar *propertyName, char **_retval)
{
if (iid->Equals(NS_GET_IID(nsISOAPEncoding))) {
*_retval = nsCRT::strdup(kAllAccess);
}
return NS_OK;
}

View File

@@ -0,0 +1,77 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Netscape 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/NPL/
*
* Software distributed under the License is distributed on an "AS
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
* implied. See the License for the specific language governing
* rights and limitations under the License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All
* Rights Reserved.
*
* Contributor(s):
*/
#ifndef nsSOAPEncodingRegistry_h__
#define nsSOAPEncodingRegistry_h__
#include "nsString.h"
#include "nsISecurityCheckedComponent.h"
#include "nsIDOMElement.h"
#include "nsISOAPEncoding.h"
#include "nsISOAPEncoder.h"
#include "nsISOAPDecoder.h"
#include "nsCOMPtr.h"
#include "nsHashtable.h"
#include "nsISchema.h"
class nsSOAPEncoding;
/* Header file */
class nsSOAPEncodingRegistry : public nsISOAPEncoding
{
public:
NS_DECL_ISUPPORTS
NS_DECL_NSISOAPENCODING
nsSOAPEncodingRegistry() {}
nsSOAPEncodingRegistry(nsISOAPEncoding* aEncoding);
virtual ~nsSOAPEncodingRegistry();
protected:
nsSupportsHashtable* mEncodings;
nsCOMPtr<nsISchemaCollection> mSchemaCollection;
};
class nsSOAPEncoding : public nsISOAPEncoding,
public nsISecurityCheckedComponent
{
public:
NS_DECL_ISUPPORTS
NS_DECL_NSISOAPENCODING
// nsISecurityCheckedComponent
NS_DECL_NSISECURITYCHECKEDCOMPONENT
nsSOAPEncoding();
nsSOAPEncoding(const nsAString& aStyleURI, nsSOAPEncodingRegistry * aRegistry, nsISOAPEncoding* aDefaultEncoding);
virtual ~nsSOAPEncoding();
/* additional members */
protected:
nsString mStyleURI;
nsSupportsHashtable* mEncoders;
nsSupportsHashtable* mDecoders;
nsCOMPtr<nsISOAPEncoding> mRegistry;
nsCOMPtr<nsISOAPEncoding> mDefaultEncoding;
nsCOMPtr<nsISOAPEncoder> mDefaultEncoder;
nsCOMPtr<nsISOAPDecoder> mDefaultDecoder;
};
#endif

View File

@@ -0,0 +1,154 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Netscape 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/NPL/
*
* Software distributed under the License is distributed on an "AS
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
* implied. See the License for the specific language governing
* rights and limitations under the License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All
* Rights Reserved.
*
* Contributor(s):
*/
#include "nsSOAPFault.h"
#include "nsSOAPUtils.h"
#include "nsIDOMNodeList.h"
nsSOAPFault::nsSOAPFault(nsIDOMElement* aElement)
{
NS_INIT_ISUPPORTS();
mFaultElement = aElement;
}
nsSOAPFault::~nsSOAPFault()
{
}
NS_IMPL_ISUPPORTS2(nsSOAPFault, nsISOAPFault, nsISecurityCheckedComponent)
/* attribute nsIDOMElement element; */
NS_IMETHODIMP nsSOAPFault::SetElement(nsIDOMElement *aElement)
{
mFaultElement = aElement;
return NS_OK;
}
NS_IMETHODIMP nsSOAPFault::GetElement(nsIDOMElement * *aElement)
{
NS_ENSURE_ARG_POINTER(aElement);
*aElement = mFaultElement;
NS_IF_ADDREF(*aElement);
return NS_OK;
}
/* readonly attribute wstring faultCode; */
NS_IMETHODIMP nsSOAPFault::GetFaultCode(nsAWritableString & aFaultCode)
{
NS_ENSURE_ARG_POINTER(&aFaultCode);
aFaultCode.Truncate();
nsCOMPtr<nsIDOMElement> faultcode;
nsSOAPUtils::GetSpecificChildElement(mFaultElement,
nsSOAPUtils::kSOAPEnvURI,
nsSOAPUtils::kFaultCodeTagName,
getter_AddRefs(faultcode));
if (faultcode) {
nsSOAPUtils::GetElementTextContent(faultcode, aFaultCode);
}
return NS_OK;
}
/* readonly attribute wstring faultString; */
NS_IMETHODIMP nsSOAPFault::GetFaultString(nsAWritableString & aFaultString)
{
NS_ENSURE_ARG_POINTER(&aFaultString);
aFaultString.Truncate();
nsCOMPtr<nsIDOMElement> element;
nsSOAPUtils::GetSpecificChildElement(mFaultElement, nsSOAPUtils::kSOAPEnvURI,
nsSOAPUtils::kFaultStringTagName, getter_AddRefs(element));
if (element) {
nsSOAPUtils::GetElementTextContent(element, aFaultString);
}
return NS_OK;
}
/* readonly attribute wstring faultActor; */
NS_IMETHODIMP nsSOAPFault::GetFaultActor(nsAWritableString & aFaultActor)
{
NS_ENSURE_ARG_POINTER(&aFaultActor);
aFaultActor.Truncate();
nsCOMPtr<nsIDOMElement> element;
nsSOAPUtils::GetSpecificChildElement(mFaultElement, nsSOAPUtils::kSOAPEnvURI,
nsSOAPUtils::kFaultActorTagName, getter_AddRefs(element));
if (element) {
nsSOAPUtils::GetElementTextContent(element, aFaultActor);
}
return NS_OK;
}
/* readonly attribute nsIDOMElement detail; */
NS_IMETHODIMP nsSOAPFault::GetDetail(nsIDOMElement * *aDetail)
{
NS_ENSURE_ARG_POINTER(aDetail);
nsCOMPtr<nsIDOMElement> element;
nsSOAPUtils::GetSpecificChildElement(mFaultElement, nsSOAPUtils::kSOAPEnvURI,
nsSOAPUtils::kFaultDetailTagName, aDetail);
return NS_OK;
}
static const char* kAllAccess = "AllAccess";
/* string canCreateWrapper (in nsIIDPtr iid); */
NS_IMETHODIMP
nsSOAPFault::CanCreateWrapper(const nsIID * iid, char **_retval)
{
if (iid->Equals(NS_GET_IID(nsISOAPFault))) {
*_retval = nsCRT::strdup(kAllAccess);
}
return NS_OK;
}
/* string canCallMethod (in nsIIDPtr iid, in wstring methodName); */
NS_IMETHODIMP
nsSOAPFault::CanCallMethod(const nsIID * iid, const PRUnichar *methodName, char **_retval)
{
if (iid->Equals(NS_GET_IID(nsISOAPFault))) {
*_retval = nsCRT::strdup(kAllAccess);
}
return NS_OK;
}
/* string canGetProperty (in nsIIDPtr iid, in wstring propertyName); */
NS_IMETHODIMP
nsSOAPFault::CanGetProperty(const nsIID * iid, const PRUnichar *propertyName, char **_retval)
{
if (iid->Equals(NS_GET_IID(nsISOAPFault))) {
*_retval = nsCRT::strdup(kAllAccess);
}
return NS_OK;
}
/* string canSetProperty (in nsIIDPtr iid, in wstring propertyName); */
NS_IMETHODIMP
nsSOAPFault::CanSetProperty(const nsIID * iid, const PRUnichar *propertyName, char **_retval)
{
if (iid->Equals(NS_GET_IID(nsISOAPFault))) {
*_retval = nsCRT::strdup(kAllAccess);
}
return NS_OK;
}

View File

@@ -0,0 +1,51 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Netscape 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/NPL/
*
* Software distributed under the License is distributed on an "AS
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
* implied. See the License for the specific language governing
* rights and limitations under the License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All
* Rights Reserved.
*
* Contributor(s):
*/
#ifndef nsSOAPFault_h__
#define nsSOAPFault_h__
#include "nsString.h"
#include "nsISOAPFault.h"
#include "nsISecurityCheckedComponent.h"
#include "nsIDOMElement.h"
#include "nsCOMPtr.h"
class nsSOAPFault : public nsISOAPFault,
public nsISecurityCheckedComponent
{
public:
nsSOAPFault(nsIDOMElement* aElement);
virtual ~nsSOAPFault();
NS_DECL_ISUPPORTS
// nsISOAPFault
NS_DECL_NSISOAPFAULT
// nsISecurityCheckedComponent
NS_DECL_NSISECURITYCHECKEDCOMPONENT
protected:
nsCOMPtr<nsIDOMElement> mFaultElement;
};
#endif

View File

@@ -0,0 +1,297 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Netscape 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/NPL/
*
* Software distributed under the License is distributed on an "AS
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
* implied. See the License for the specific language governing
* rights and limitations under the License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All
* Rights Reserved.
*
* Contributor(s):
*/
#include "nsString.h"
#include "nsReadableUtils.h"
#include "nsSOAPHeaderBlock.h"
#include "nsSOAPUtils.h"
#include "nsIServiceManager.h"
#include "nsISOAPAttachments.h"
nsSOAPHeaderBlock::nsSOAPHeaderBlock()
{
NS_INIT_ISUPPORTS();
}
nsSOAPHeaderBlock::~nsSOAPHeaderBlock()
{
}
NS_IMPL_ISUPPORTS3_CI(nsSOAPHeaderBlock,
nsISOAPHeaderBlock,
nsISecurityCheckedComponent,
nsIJSNativeInitializer)
/* attribute AString namespaceURI; */
NS_IMETHODIMP nsSOAPHeaderBlock::GetNamespaceURI(nsAWritableString & aNamespaceURI)
{
NS_ENSURE_ARG_POINTER(&aNamespaceURI);
if (mElement) {
return mElement->GetNamespaceURI(aNamespaceURI);
}
else {
aNamespaceURI.Assign(mNamespaceURI);
}
return NS_OK;
}
NS_IMETHODIMP nsSOAPHeaderBlock::SetNamespaceURI(const nsAReadableString & aNamespaceURI)
{
if (mElement) {
return NS_ERROR_FAILURE;
}
mNamespaceURI.Assign(aNamespaceURI);
return NS_OK;
}
/* attribute AString name; */
NS_IMETHODIMP nsSOAPHeaderBlock::GetName(nsAWritableString & aName)
{
NS_ENSURE_ARG_POINTER(&aName);
if (mElement) {
return mElement->GetLocalName(aName);
}
else {
aName.Assign(mName);
}
return NS_OK;
}
NS_IMETHODIMP nsSOAPHeaderBlock::SetName(const nsAReadableString & aName)
{
if (mElement) {
return NS_ERROR_FAILURE;
}
mName.Assign(aName);
return NS_OK;
}
/* attribute AString actorURI; */
NS_IMETHODIMP nsSOAPHeaderBlock::GetActorURI(nsAWritableString & aActorURI)
{
NS_ENSURE_ARG_POINTER(&aActorURI);
if (mElement) {
return mElement->GetAttributeNS(nsSOAPUtils::kSOAPEnvURI,nsSOAPUtils::kActorAttribute,aActorURI);
}
else {
aActorURI.Assign(mActorURI);
}
return NS_OK;
}
NS_IMETHODIMP nsSOAPHeaderBlock::SetActorURI(const nsAReadableString & aActorURI)
{
if (mElement) {
return NS_ERROR_FAILURE;
}
mActorURI.Assign(aActorURI);
return NS_OK;
}
/* attribute nsISOAPEncoding encoding; */
NS_IMETHODIMP nsSOAPHeaderBlock::GetEncoding(nsISOAPEncoding* * aEncoding)
{
NS_ENSURE_ARG_POINTER(aEncoding);
*aEncoding = mEncoding;
NS_IF_ADDREF(*aEncoding);
return NS_OK;
}
NS_IMETHODIMP nsSOAPHeaderBlock::SetEncoding(nsISOAPEncoding* aEncoding)
{
mEncoding = aEncoding;
if (mElement) {
mComputeValue = PR_TRUE;
mValue = nsnull;
mStatus = NS_OK;
}
return NS_OK;
}
/* attribute nsISchemaType schemaType; */
NS_IMETHODIMP nsSOAPHeaderBlock::GetSchemaType(nsISchemaType* * aSchemaType)
{
NS_ENSURE_ARG_POINTER(aSchemaType);
*aSchemaType = mSchemaType;
NS_IF_ADDREF(*aSchemaType);
return NS_OK;
}
NS_IMETHODIMP nsSOAPHeaderBlock::SetSchemaType(nsISchemaType* aSchemaType)
{
mSchemaType = aSchemaType;
if (mElement) {
mComputeValue = PR_TRUE;
mValue = nsnull;
mStatus = NS_OK;
}
return NS_OK;
}
/* attribute nsISOAPAttachments attachments; */
NS_IMETHODIMP nsSOAPHeaderBlock::GetAttachments(nsISOAPAttachments* * aAttachments)
{
NS_ENSURE_ARG_POINTER(aAttachments);
*aAttachments = mAttachments;
NS_IF_ADDREF(*aAttachments);
return NS_OK;
}
NS_IMETHODIMP nsSOAPHeaderBlock::SetAttachments(nsISOAPAttachments* aAttachments)
{
mAttachments = aAttachments;
if (mElement) {
mComputeValue = PR_TRUE;
mValue = nsnull;
mStatus = NS_OK;
}
return NS_OK;
}
/* attribute nsIDOMElement element; */
NS_IMETHODIMP nsSOAPHeaderBlock::GetElement(nsIDOMElement* * aElement)
{
NS_ENSURE_ARG_POINTER(aElement);
*aElement = mElement;
NS_IF_ADDREF(*aElement);
return NS_OK;
}
NS_IMETHODIMP nsSOAPHeaderBlock::SetElement(nsIDOMElement* aElement)
{
mElement = aElement;
mNamespaceURI.SetLength(0);
mName.SetLength(0);
mActorURI.SetLength(0);
mComputeValue = PR_TRUE;
mValue = nsnull;
mStatus = NS_OK;
return NS_OK;
}
/* attribute nsIVariant value; */
NS_IMETHODIMP nsSOAPHeaderBlock::GetValue(nsIVariant* * aValue)
{
NS_ENSURE_ARG_POINTER(aValue);
if (mElement // Check for auto-computation
&& mComputeValue
&& mEncoding)
{
mComputeValue = PR_FALSE;
mStatus = mEncoding->Decode(mElement, mSchemaType, mAttachments, getter_AddRefs(mValue));
}
*aValue = mValue;
NS_IF_ADDREF(*aValue);
return mElement ? mStatus : NS_OK;
}
NS_IMETHODIMP nsSOAPHeaderBlock::SetValue(nsIVariant* aValue)
{
mValue = aValue;
mComputeValue = PR_FALSE;
mElement = nsnull;
return NS_OK;
}
NS_IMETHODIMP
nsSOAPHeaderBlock::Initialize(JSContext *cx, JSObject *obj,
PRUint32 argc, jsval *argv)
{
// Get the arguments.
nsCOMPtr<nsIVariant> value;
nsAutoString name;
nsAutoString namespaceURI;
nsAutoString actorURI;
nsCOMPtr<nsISupports> schemaType;
nsCOMPtr<nsISupports> encoding;
if (!JS_ConvertArguments(cx, argc, argv, "/%iv %is %is %is %ip %ip",
getter_AddRefs(value),
NS_STATIC_CAST(nsAString*, &name),
NS_STATIC_CAST(nsAString*, &namespaceURI),
NS_STATIC_CAST(nsAString*, &actorURI),
getter_AddRefs(schemaType),
getter_AddRefs(encoding))) return NS_ERROR_ILLEGAL_VALUE;
nsresult rc = SetValue(value);
if (NS_FAILED(rc)) return rc;
rc = SetName(name);
if (NS_FAILED(rc)) return rc;
rc = SetNamespaceURI(namespaceURI);
if (NS_FAILED(rc)) return rc;
rc = SetActorURI(actorURI);
if (NS_FAILED(rc)) return rc;
if (schemaType) {
nsCOMPtr<nsISchemaType> v = do_QueryInterface(schemaType, &rc);
if (NS_FAILED(rc)) return rc;
rc = SetSchemaType(v);
if (NS_FAILED(rc)) return rc;
}
if (encoding) {
nsCOMPtr<nsISOAPEncoding> v = do_QueryInterface(encoding, &rc);
if (NS_FAILED(rc)) return rc;
rc = SetEncoding(v);
if (NS_FAILED(rc)) return rc;
}
return NS_OK;
}
static const char* kAllAccess = "AllAccess";
/* string canCreateWrapper (in nsIIDPtr iid); */
NS_IMETHODIMP
nsSOAPHeaderBlock::CanCreateWrapper(const nsIID * iid, char **_retval)
{
if (iid->Equals(NS_GET_IID(nsISOAPHeaderBlock))) {
*_retval = nsCRT::strdup(kAllAccess);
}
return NS_OK;
}
/* string canCallMethod (in nsIIDPtr iid, in wstring methodName); */
NS_IMETHODIMP
nsSOAPHeaderBlock::CanCallMethod(const nsIID * iid, const PRUnichar *methodName, char **_retval)
{
if (iid->Equals(NS_GET_IID(nsISOAPHeaderBlock))) {
*_retval = nsCRT::strdup(kAllAccess);
}
return NS_OK;
}
/* string canGetProperty (in nsIIDPtr iid, in wstring propertyName); */
NS_IMETHODIMP
nsSOAPHeaderBlock::CanGetProperty(const nsIID * iid, const PRUnichar *propertyName, char **_retval)
{
if (iid->Equals(NS_GET_IID(nsISOAPHeaderBlock))) {
*_retval = nsCRT::strdup(kAllAccess);
}
return NS_OK;
}
/* string canSetProperty (in nsIIDPtr iid, in wstring propertyName); */
NS_IMETHODIMP
nsSOAPHeaderBlock::CanSetProperty(const nsIID * iid, const PRUnichar *propertyName, char **_retval)
{
if (iid->Equals(NS_GET_IID(nsISOAPHeaderBlock))) {
*_retval = nsCRT::strdup(kAllAccess);
}
return NS_OK;
}

View File

@@ -0,0 +1,70 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Netscape 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/NPL/
*
* Software distributed under the License is distributed on an "AS
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
* implied. See the License for the specific language governing
* rights and limitations under the License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All
* Rights Reserved.
*
* Contributor(s):
*/
#ifndef nsSOAPHeaderBlock_h__
#define nsSOAPHeaderBlock_h__
#include "nsString.h"
#include "nsIVariant.h"
#include "nsISOAPHeaderBlock.h"
#include "nsISecurityCheckedComponent.h"
#include "nsIJSNativeInitializer.h"
#include "nsISOAPEncoding.h"
#include "nsISchema.h"
#include "nsIDOMElement.h"
#include "nsISOAPAttachments.h"
#include "nsCOMPtr.h"
class nsSOAPHeaderBlock : public nsISOAPHeaderBlock,
public nsISecurityCheckedComponent,
public nsIJSNativeInitializer
{
public:
nsSOAPHeaderBlock();
virtual ~nsSOAPHeaderBlock();
NS_DECL_ISUPPORTS
// nsISOAPHeaderBlock
NS_DECL_NSISOAPHEADERBLOCK
// nsISecurityCheckedComponent
NS_DECL_NSISECURITYCHECKEDCOMPONENT
// nsIJSNativeInitializer
NS_IMETHOD Initialize(JSContext *cx, JSObject *obj,
PRUint32 argc, jsval *argv);
protected:
nsString mNamespaceURI;
nsString mName;
nsString mActorURI;
nsCOMPtr<nsISOAPEncoding> mEncoding;
nsCOMPtr<nsISchemaType> mSchemaType;
nsCOMPtr<nsISOAPAttachments> mAttachments;
nsCOMPtr<nsIDOMElement> mElement;
nsCOMPtr<nsIVariant> mValue;
nsresult mStatus;
PRBool mComputeValue;
};
#endif

View File

@@ -0,0 +1,475 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Netscape 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/NPL/
*
* Software distributed under the License is distributed on an "AS
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
* implied. See the License for the specific language governing
* rights and limitations under the License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All
* Rights Reserved.
*
* Contributor(s):
*/
#include "nsIServiceManager.h"
#include "nsMemory.h"
#include "nsIComponentManager.h"
#include "nsSOAPUtils.h"
#include "nsSOAPMessage.h"
#include "nsSOAPParameter.h"
#include "nsSOAPHeaderBlock.h"
#include "nsSOAPEncoding.h"
#include "nsIDOMDocument.h"
#include "nsIDOMParser.h"
#include "nsIDOMElement.h"
#include "nsIDOMNamedNodeMap.h"
static NS_DEFINE_CID(kDOMParserCID, NS_DOMPARSER_CID);
/////////////////////////////////////////////
//
//
/////////////////////////////////////////////
nsSOAPMessage::nsSOAPMessage()
{
NS_INIT_ISUPPORTS();
}
nsSOAPMessage::~nsSOAPMessage()
{
}
NS_IMPL_ISUPPORTS2(nsSOAPMessage,
nsISOAPMessage,
nsISecurityCheckedComponent)
/* attribute nsIDOMDocument message; */
NS_IMETHODIMP nsSOAPMessage::GetMessage(nsIDOMDocument * *aMessage)
{
NS_ENSURE_ARG_POINTER(aMessage);
*aMessage = mMessage;
NS_IF_ADDREF(*aMessage);
return NS_OK;
}
NS_IMETHODIMP nsSOAPMessage::SetMessage(nsIDOMDocument * aMessage)
{
mMessage = aMessage;
return NS_OK;
}
/* readonly attribute nsIDOMElement envelope; */
NS_IMETHODIMP nsSOAPMessage::GetEnvelope(nsIDOMElement * *aEnvelope)
{
NS_ENSURE_ARG_POINTER(aEnvelope);
if (mMessage) {
nsCOMPtr<nsIDOMElement> root;
mMessage->GetDocumentElement(getter_AddRefs(root));
if (root) {
nsAutoString name, namespaceURI;
root->GetLocalName(name);
root->GetNamespaceURI(namespaceURI);
if (name.Equals(nsSOAPUtils::kEnvelopeTagName)
&& namespaceURI.Equals(nsSOAPUtils::kSOAPEnvURI))
{
*aEnvelope = root;
NS_ADDREF(*aEnvelope);
return NS_OK;
}
}
}
*aEnvelope = nsnull;
return NS_OK;
}
/* readonly attribute nsIDOMElement header; */
NS_IMETHODIMP nsSOAPMessage::GetHeader(nsIDOMElement * *aHeader)
{
NS_ENSURE_ARG_POINTER(aHeader);
nsCOMPtr<nsIDOMElement> env;
GetEnvelope(getter_AddRefs(env));
if (env) {
nsSOAPUtils::GetSpecificChildElement(env,
nsSOAPUtils::kSOAPEnvURI, nsSOAPUtils::kHeaderTagName,
aHeader);
}
else {
*aHeader = nsnull;
}
return NS_OK;
}
/* readonly attribute nsIDOMElement body; */
NS_IMETHODIMP nsSOAPMessage::GetBody(nsIDOMElement * *aBody)
{
NS_ENSURE_ARG_POINTER(aBody);
nsCOMPtr<nsIDOMElement> env;
GetEnvelope(getter_AddRefs(env));
if (env) {
nsSOAPUtils::GetSpecificChildElement(env,
nsSOAPUtils::kSOAPEnvURI, nsSOAPUtils::kBodyTagName,
aBody);
}
else {
*aBody = nsnull;
}
return NS_OK;
}
/* attribute DOMString actionURI; */
NS_IMETHODIMP nsSOAPMessage::GetActionURI(nsAWritableString & aActionURI)
{
NS_ENSURE_ARG_POINTER(&aActionURI);
aActionURI.Assign(mActionURI);
return NS_OK;
}
NS_IMETHODIMP nsSOAPMessage::SetActionURI(const nsAReadableString & aActionURI)
{
mActionURI.Assign(aActionURI);
return NS_OK;
}
/* readonly attribute AString methodName; */
NS_IMETHODIMP nsSOAPMessage::GetMethodName(nsAString & aMethodName)
{
NS_ENSURE_ARG_POINTER(&aMethodName);
nsCOMPtr<nsIDOMElement> body;
GetBody(getter_AddRefs(body));
if (body) {
nsCOMPtr<nsIDOMElement> method;
nsSOAPUtils::GetFirstChildElement(body, getter_AddRefs(method));
if (method) {
body->GetLocalName(aMethodName);
return NS_OK;
}
}
aMethodName.SetLength(0);
return NS_OK;
}
/* readonly attribute AString targetObjectURI; */
NS_IMETHODIMP nsSOAPMessage::GetTargetObjectURI(nsAString & aTargetObjectURI)
{
NS_ENSURE_ARG_POINTER(&aTargetObjectURI);
nsCOMPtr<nsIDOMElement> body;
GetBody(getter_AddRefs(body));
if (body) {
nsCOMPtr<nsIDOMElement> method;
nsSOAPUtils::GetFirstChildElement(body, getter_AddRefs(method));
if (method) {
body->GetNamespaceURI(aTargetObjectURI);
return NS_OK;
}
}
aTargetObjectURI.SetLength(0);
return NS_OK;
}
NS_NAMED_LITERAL_STRING(kEmptySOAPDocStr, "<SOAP-ENV:Envelope xmlns:SOAP-ENV=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:SOAP-ENC=\"http://schemas.xmlsoap.org/soap/encoding/\" xmlns:xsi=\"http://www.w3.org/1999/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/1999/XMLSchema\"><SOAP-ENV:Header></SOAP-ENV:Header><SOAP-ENV:Body></SOAP-ENV:Body></SOAP-ENV:Envelope>");
/* void encode (in AString aMethodName, in AString aTargetObjectURI, in PRUint32 aHeaderBlockCount, [array, size_is (aHeaderBlockCount)] in nsISOAPHeaderBlock aHeaderBlocks, in PRUint32 aParameterCount, [array, size_is (aParameterCount)] in nsISOAPParameter aParameters); */
NS_IMETHODIMP nsSOAPMessage::Encode(const nsAString & aMethodName, const nsAString & aTargetObjectURI, PRUint32 aHeaderBlockCount, nsISOAPHeaderBlock **aHeaderBlocks, PRUint32 aParameterCount, nsISOAPParameter **aParameters)
{
// Construct the message skeleton
nsresult rv;
nsCOMPtr<nsIDOMNode> ignored;
nsCOMPtr<nsIDOMParser> parser = do_CreateInstance(kDOMParserCID, &rv);
if (NS_FAILED(rv)) return rv;
nsAutoString docstr;
rv = parser->ParseFromString(kEmptySOAPDocStr.get(), "text/xml",
getter_AddRefs(mMessage));
if (NS_FAILED(rv)) return rv;
// Declare the default encoding if one exists
if (mEncoding) {
nsCOMPtr<nsIDOMElement> envelope;
rv = GetEnvelope(getter_AddRefs(envelope));
if (NS_FAILED(rv)) return rv;
if (envelope) {
nsAutoString enc;
mEncoding->GetStyleURI(enc);
envelope->SetAttributeNS(nsSOAPUtils::kSOAPEncodingURI, nsSOAPUtils::kEncodingStyleAttribute, enc);
}
}
// Encode and add headers, if any were specified
if (aHeaderBlockCount) {
nsCOMPtr<nsIDOMElement> parent;
rv = GetHeader(getter_AddRefs(parent));
if (NS_FAILED(rv)) return rv;
nsCOMPtr<nsISupports> next;
nsCOMPtr<nsISOAPHeaderBlock> header;
nsCOMPtr<nsIDOMElement> element;
nsCOMPtr<nsISOAPEncoding> encoding;
nsCOMPtr<nsISchemaType> schemaType;
nsCOMPtr<nsIVariant> value;
nsAutoString name;
nsAutoString namespaceURI;
nsAutoString actorURI;
for (PRUint32 i = 0; i < aHeaderBlockCount; i++) {
header = aHeaderBlocks[i];
if (!header) return NS_ERROR_FAILURE;
rv = header->GetElement(getter_AddRefs(element));
if (element) {
nsCOMPtr<nsIDOMNode> node1 = (nsIDOMElement*)element;
nsCOMPtr<nsIDOMNode> node2;
rv = mMessage->ImportNode(node1, PR_TRUE, getter_AddRefs(node1));
if (NS_FAILED(rv)) return rv;
rv = parent->AppendChild(node2, getter_AddRefs(node1));
if (NS_FAILED(rv)) return rv;
element = do_QueryInterface(node1);
}
else {
rv = header->GetNamespaceURI(namespaceURI);
if (NS_FAILED(rv)) return rv;
rv = header->GetName(name);
if (NS_FAILED(rv)) return rv;
rv = header->GetActorURI(actorURI);
if (NS_FAILED(rv)) return rv;
rv = header->GetEncoding(getter_AddRefs(encoding));
if (NS_FAILED(rv)) return rv;
if (!encoding) {
encoding = mEncoding;
}
rv = header->GetSchemaType(getter_AddRefs(schemaType));
if (NS_FAILED(rv)) return rv;
rv = header->GetValue(getter_AddRefs(value));
if (NS_FAILED(rv)) return rv;
rv = encoding->Encode(value, namespaceURI, name,
schemaType, nsnull, parent, getter_AddRefs(element));
if (NS_FAILED(rv)) return rv;
if (!actorURI.IsEmpty()) {
element->SetAttributeNS(nsSOAPUtils::kSOAPEnvPrefix, nsSOAPUtils::kActorAttribute, actorURI);
}
if (mEncoding != encoding) {
nsAutoString enc;
encoding->GetStyleURI(enc);
element->SetAttributeNS(nsSOAPUtils::kSOAPEncodingURI, nsSOAPUtils::kEncodingStyleAttribute, enc);
}
}
}
}
nsCOMPtr<nsIDOMElement> body;
rv = GetBody(getter_AddRefs(body));
if (NS_FAILED(rv)) return rv;
// Only produce a call element if mMethodName was non-empty
if (!aMethodName.IsEmpty()) {
nsCOMPtr<nsIDOMElement> call;
rv = mMessage->CreateElementNS(aTargetObjectURI, aMethodName, getter_AddRefs(call));
if (NS_FAILED(rv)) return rv;
nsCOMPtr<nsIDOMNode> ignored;
rv = body->AppendChild(call, getter_AddRefs(ignored));
if (NS_FAILED(rv)) return rv;
body = call;
nsAutoString prefix;
rv = nsSOAPUtils::MakeNamespacePrefixFixed(body, aTargetObjectURI, prefix);
if (NS_FAILED(rv)) return rv;
if (!prefix.IsEmpty()) {
rv = body->SetPrefix(prefix);
if (NS_FAILED(rv)) return rv;
}
}
// Encode and add all of the parameters into the body
nsCOMPtr<nsISupports> next;
nsCOMPtr<nsISOAPParameter> param;
nsCOMPtr<nsIDOMElement> element;
nsCOMPtr<nsISOAPEncoding> encoding;
nsCOMPtr<nsISchemaType> schemaType;
nsCOMPtr<nsIVariant> value;
nsAutoString name;
nsAutoString namespaceURI;
for (PRUint32 i = 0; i < aParameterCount; i++) {
param = aParameters[i];
if (!param) return NS_ERROR_FAILURE;
rv = param->GetElement(getter_AddRefs(element));
if (element) {
nsCOMPtr<nsIDOMNode> node1 = (nsIDOMElement*)element;
nsCOMPtr<nsIDOMNode> node2;
rv = mMessage->ImportNode(node1, PR_TRUE, getter_AddRefs(node1));
if (NS_FAILED(rv)) return rv;
rv = body->AppendChild(node2, getter_AddRefs(node1));
if (NS_FAILED(rv)) return rv;
element = do_QueryInterface(node1);
}
else {
rv = param->GetNamespaceURI(namespaceURI);
if (NS_FAILED(rv)) return rv;
rv = param->GetName(name);
if (NS_FAILED(rv)) return rv;
rv = param->GetEncoding(getter_AddRefs(encoding));
if (NS_FAILED(rv)) return rv;
if (!encoding) {
encoding = mEncoding;
}
rv = param->GetSchemaType(getter_AddRefs(schemaType));
if (NS_FAILED(rv)) return rv;
rv = param->GetValue(getter_AddRefs(value));
if (NS_FAILED(rv)) return rv;
rv = encoding->Encode(value, namespaceURI, name,
schemaType, nsnull, body, getter_AddRefs(element));
if (NS_FAILED(rv)) return rv;
if (mEncoding != encoding) {
nsAutoString enc;
encoding->GetStyleURI(enc);
element->SetAttributeNS(nsSOAPUtils::kSOAPEncodingURI, nsSOAPUtils::kEncodingStyleAttribute, enc);
}
}
}
return NS_OK;
}
static NS_DEFINE_CID(kMemoryCID, NS_MEMORY_CID);
/* void getHeaderBlocks (out PRUint32 aCount, [array, size_is (aCount), retval] out nsISOAPHeaderBlock aHeaderBlocks); */
NS_IMETHODIMP nsSOAPMessage::GetHeaderBlocks(PRUint32 *aCount, nsISOAPHeaderBlock ***aHeaderBlocks)
{
nsCOMPtr<nsIMemory> memory = do_GetService(kMemoryCID);
*aCount = 0;
*aHeaderBlocks = nsnull;
int count = 0;
int length = 0;
nsCOMPtr<nsIDOMElement> element;
nsresult rv = GetHeader(getter_AddRefs(element));
if (NS_FAILED(rv)) return rv;
nsCOMPtr<nsIDOMElement> next;
nsCOMPtr<nsISOAPHeaderBlock> header;
nsSOAPUtils::GetFirstChildElement(element, getter_AddRefs(next));
while (next) {
if (length == count) {
length = length ? 2 * length : 10;
*aHeaderBlocks = (nsISOAPHeaderBlock* *)memory->Realloc(*aHeaderBlocks, length * sizeof(**aHeaderBlocks));
}
element = next;
header = new nsSOAPHeaderBlock();
if (NS_FAILED(rv)) return rv;
// XXX can't addref a COMPTr
//NS_ADDREF(header);
(*aHeaderBlocks)[(*aCount)++] = header;
rv = header->SetElement(element);
if (NS_FAILED(rv)) return rv;
nsSOAPUtils::GetNextSiblingElement(element, getter_AddRefs(next));
}
if (*aCount) {
*aHeaderBlocks = (nsISOAPHeaderBlock* *)memory->Realloc(*aHeaderBlocks, (*aCount) * sizeof(**aHeaderBlocks));
}
return NS_OK;
}
/* void getParameters (in boolean aDocumentStyle, out PRUint32 aCount, [array, size_is (aCount), retval] out nsISOAPParameter aParameters); */
NS_IMETHODIMP nsSOAPMessage::GetParameters(PRBool aDocumentStyle, PRUint32 *aCount, nsISOAPParameter ***aParameters)
{
nsCOMPtr<nsIMemory> memory = do_GetService(kMemoryCID);
*aCount = 0;
*aParameters = nsnull;
int count = 0;
int length = 0;
nsCOMPtr<nsIDOMElement> element;
nsresult rv = GetHeader(getter_AddRefs(element));
if (NS_FAILED(rv)) return rv;
nsCOMPtr<nsIDOMElement> next;
nsCOMPtr<nsISOAPParameter> param;
nsSOAPUtils::GetFirstChildElement(element, getter_AddRefs(next));
while (next) {
if (length == count) {
length = length ? 2 * length : 10;
*aParameters = (nsISOAPParameter* *)memory->Realloc(*aParameters, length * sizeof(**aParameters));
}
element = next;
param = new nsSOAPParameter();
if (NS_FAILED(rv)) return rv;
// XXX can't addref a COMPTr
//NS_ADDREF(param);
(*aParameters)[(*aCount)++] = param;
rv = param->SetElement(element);
if (NS_FAILED(rv)) return rv;
nsSOAPUtils::GetNextSiblingElement(element, getter_AddRefs(next));
}
if (*aCount) {
*aParameters = (nsISOAPParameter* *)memory->Realloc(*aParameters, (*aCount) * sizeof(**aParameters));
}
return NS_OK;
}
/* attribute nsISOAPEncoding encoding; */
NS_IMETHODIMP nsSOAPMessage::GetEncoding(nsISOAPEncoding* * aEncoding)
{
NS_ENSURE_ARG_POINTER(aEncoding);
if (!mEncoding) {
mEncoding = new nsSOAPEncoding();
if (!mEncoding)
return NS_ERROR_OUT_OF_MEMORY;
}
*aEncoding = mEncoding;
NS_IF_ADDREF(*aEncoding);
return NS_OK;
}
NS_IMETHODIMP nsSOAPMessage::SetEncoding(nsISOAPEncoding* aEncoding)
{
mEncoding = aEncoding;
return NS_OK;
}
static const char*kAllAccess = "AllAccess";
/* string canCreateWrapper (in nsIIDPtr iid); */
NS_IMETHODIMP
nsSOAPMessage::CanCreateWrapper(const nsIID * iid, char**_retval)
{
if (iid->Equals(NS_GET_IID(nsISOAPMessage))) {
*_retval = nsCRT::strdup(kAllAccess);
}
return NS_OK;
}
/* string canCallMethod (in nsIIDPtr iid, in wstring methodName); */
NS_IMETHODIMP
nsSOAPMessage::CanCallMethod(const nsIID * iid, const PRUnichar*methodName, char**_retval)
{
if (iid->Equals(NS_GET_IID(nsISOAPMessage))) {
*_retval = nsCRT::strdup(kAllAccess);
}
return NS_OK;
}
/* string canGetProperty (in nsIIDPtr iid, in wstring propertyName); */
NS_IMETHODIMP
nsSOAPMessage::CanGetProperty(const nsIID * iid, const PRUnichar*propertyName, char**_retval)
{
if (iid->Equals(NS_GET_IID(nsISOAPMessage))) {
*_retval = nsCRT::strdup(kAllAccess);
}
return NS_OK;
}
/* string canSetProperty (in nsIIDPtr iid, in wstring propertyName); */
NS_IMETHODIMP
nsSOAPMessage::CanSetProperty(const nsIID * iid, const PRUnichar*propertyName, char**_retval)
{
if (iid->Equals(NS_GET_IID(nsISOAPMessage))) {
*_retval = nsCRT::strdup(kAllAccess);
}
return NS_OK;
}

View File

@@ -0,0 +1,58 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Netscape 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/NPL/
*
* Software distributed under the License is distributed on an "AS
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
* implied. See the License for the specific language governing
* rights and limitations under the License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All
* Rights Reserved.
*
* Contributor(s):
*/
#ifndef nsSOAPMessage_h__
#define nsSOAPMessage_h__
#include "nsString.h"
#include "nsISOAPEncoding.h"
#include "nsISOAPMessage.h"
#include "nsISecurityCheckedComponent.h"
#include "nsIDOMElement.h"
#include "nsIDOMDocument.h"
#include "nsISupportsArray.h"
#include "nsCOMPtr.h"
#include "nsIVariant.h"
class nsSOAPMessage : public nsISOAPMessage,
public nsISecurityCheckedComponent
{
public:
nsSOAPMessage();
virtual ~nsSOAPMessage();
NS_DECL_ISUPPORTS
// nsISOAPMessage
NS_DECL_NSISOAPMESSAGE
// nsISecurityCheckedComponent
NS_DECL_NSISECURITYCHECKEDCOMPONENT
protected:
nsCOMPtr<nsIDOMDocument> mMessage;
nsCOMPtr<nsISOAPEncoding> mEncoding;
nsString mActionURI;
};
#endif

View File

@@ -0,0 +1,271 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Netscape 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/NPL/
*
* Software distributed under the License is distributed on an "AS
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
* implied. See the License for the specific language governing
* rights and limitations under the License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All
* Rights Reserved.
*
* Contributor(s):
*/
#include "nsString.h"
#include "nsReadableUtils.h"
#include "nsSOAPParameter.h"
#include "nsSOAPUtils.h"
#include "nsIServiceManager.h"
#include "nsISOAPAttachments.h"
nsSOAPParameter::nsSOAPParameter()
{
NS_INIT_ISUPPORTS();
}
nsSOAPParameter::~nsSOAPParameter()
{
}
NS_IMPL_ISUPPORTS3_CI(nsSOAPParameter,
nsISOAPParameter,
nsISecurityCheckedComponent,
nsIJSNativeInitializer)
/* attribute AString namespaceURI; */
NS_IMETHODIMP nsSOAPParameter::GetNamespaceURI(nsAWritableString & aNamespaceURI)
{
NS_ENSURE_ARG_POINTER(&aNamespaceURI);
if (mElement) {
return mElement->GetNamespaceURI(aNamespaceURI);
}
else {
aNamespaceURI.Assign(mNamespaceURI);
}
return NS_OK;
}
NS_IMETHODIMP nsSOAPParameter::SetNamespaceURI(const nsAReadableString & aNamespaceURI)
{
if (mElement) {
return NS_ERROR_FAILURE;
}
mNamespaceURI.Assign(aNamespaceURI);
return NS_OK;
}
/* attribute AString name; */
NS_IMETHODIMP nsSOAPParameter::GetName(nsAWritableString & aName)
{
NS_ENSURE_ARG_POINTER(&aName);
if (mElement) {
return mElement->GetLocalName(aName);
}
else {
aName.Assign(mName);
}
return NS_OK;
}
NS_IMETHODIMP nsSOAPParameter::SetName(const nsAReadableString & aName)
{
if (mElement) {
return NS_ERROR_FAILURE;
}
mName.Assign(aName);
return NS_OK;
}
/* attribute nsISOAPEncoding encoding; */
NS_IMETHODIMP nsSOAPParameter::GetEncoding(nsISOAPEncoding* * aEncoding)
{
NS_ENSURE_ARG_POINTER(aEncoding);
*aEncoding = mEncoding;
NS_IF_ADDREF(*aEncoding);
return NS_OK;
}
NS_IMETHODIMP nsSOAPParameter::SetEncoding(nsISOAPEncoding* aEncoding)
{
mEncoding = aEncoding;
if (mElement) {
mComputeValue = PR_TRUE;
mValue = nsnull;
mStatus = NS_OK;
}
return NS_OK;
}
/* attribute nsISchemaType schemaType; */
NS_IMETHODIMP nsSOAPParameter::GetSchemaType(nsISchemaType* * aSchemaType)
{
NS_ENSURE_ARG_POINTER(aSchemaType);
*aSchemaType = mSchemaType;
NS_IF_ADDREF(*aSchemaType);
return NS_OK;
}
NS_IMETHODIMP nsSOAPParameter::SetSchemaType(nsISchemaType* aSchemaType)
{
mSchemaType = aSchemaType;
if (mElement) {
mComputeValue = PR_TRUE;
mValue = nsnull;
mStatus = NS_OK;
}
return NS_OK;
}
/* attribute nsISOAPAttachments attachments; */
NS_IMETHODIMP nsSOAPParameter::GetAttachments(nsISOAPAttachments* * aAttachments)
{
NS_ENSURE_ARG_POINTER(aAttachments);
*aAttachments = mAttachments;
NS_IF_ADDREF(*aAttachments);
return NS_OK;
}
NS_IMETHODIMP nsSOAPParameter::SetAttachments(nsISOAPAttachments* aAttachments)
{
mAttachments = aAttachments;
if (mElement) {
mComputeValue = PR_TRUE;
mValue = nsnull;
mStatus = NS_OK;
}
return NS_OK;
}
/* attribute nsIDOMElement element; */
NS_IMETHODIMP nsSOAPParameter::GetElement(nsIDOMElement* * aElement)
{
NS_ENSURE_ARG_POINTER(aElement);
*aElement = mElement;
NS_IF_ADDREF(*aElement);
return NS_OK;
}
NS_IMETHODIMP nsSOAPParameter::SetElement(nsIDOMElement* aElement)
{
mElement = aElement;
mNamespaceURI.SetLength(0);
mName.SetLength(0);
mComputeValue = PR_TRUE;
mValue = nsnull;
mStatus = NS_OK;
return NS_OK;
}
/* attribute nsIVariant value; */
NS_IMETHODIMP nsSOAPParameter::GetValue(nsIVariant* * aValue)
{
NS_ENSURE_ARG_POINTER(aValue);
if (mElement // Check for auto-computation
&& mComputeValue
&& mEncoding)
{
mComputeValue = PR_FALSE;
mStatus = mEncoding->Decode(mElement, mSchemaType, mAttachments, getter_AddRefs(mValue));
}
*aValue = mValue;
NS_IF_ADDREF(*aValue);
return mElement ? mStatus : NS_OK;
}
NS_IMETHODIMP nsSOAPParameter::SetValue(nsIVariant* aValue)
{
mValue = aValue;
mComputeValue = PR_FALSE;
mElement = nsnull;
return NS_OK;
}
NS_IMETHODIMP
nsSOAPParameter::Initialize(JSContext *cx, JSObject *obj,
PRUint32 argc, jsval *argv)
{
// Get the arguments.
nsCOMPtr<nsIVariant> value;
nsAutoString name;
nsAutoString namespaceURI;
nsCOMPtr<nsISupports> schemaType;
nsCOMPtr<nsISupports> encoding;
if (!JS_ConvertArguments(cx, argc, argv, "/%iv %is %is %ip %ip",
getter_AddRefs(value),
NS_STATIC_CAST(nsAString*, &name),
NS_STATIC_CAST(nsAString*, &namespaceURI),
getter_AddRefs(schemaType),
getter_AddRefs(encoding))) return NS_ERROR_ILLEGAL_VALUE;
nsresult rc = SetValue(value);
if (NS_FAILED(rc)) return rc;
rc = SetName(name);
if (NS_FAILED(rc)) return rc;
rc = SetNamespaceURI(namespaceURI);
if (NS_FAILED(rc)) return rc;
if (schemaType) {
nsCOMPtr<nsISchemaType> v = do_QueryInterface(schemaType, &rc);
if (NS_FAILED(rc)) return rc;
rc = SetSchemaType(v);
if (NS_FAILED(rc)) return rc;
}
if (encoding) {
nsCOMPtr<nsISOAPEncoding> v = do_QueryInterface(encoding, &rc);
if (NS_FAILED(rc)) return rc;
rc = SetEncoding(v);
if (NS_FAILED(rc)) return rc;
}
return NS_OK;
}
static const char* kAllAccess = "AllAccess";
/* string canCreateWrapper (in nsIIDPtr iid); */
NS_IMETHODIMP
nsSOAPParameter::CanCreateWrapper(const nsIID * iid, char **_retval)
{
if (iid->Equals(NS_GET_IID(nsISOAPParameter))) {
*_retval = nsCRT::strdup(kAllAccess);
}
return NS_OK;
}
/* string canCallMethod (in nsIIDPtr iid, in wstring methodName); */
NS_IMETHODIMP
nsSOAPParameter::CanCallMethod(const nsIID * iid, const PRUnichar *methodName, char **_retval)
{
if (iid->Equals(NS_GET_IID(nsISOAPParameter))) {
*_retval = nsCRT::strdup(kAllAccess);
}
return NS_OK;
}
/* string canGetProperty (in nsIIDPtr iid, in wstring propertyName); */
NS_IMETHODIMP
nsSOAPParameter::CanGetProperty(const nsIID * iid, const PRUnichar *propertyName, char **_retval)
{
if (iid->Equals(NS_GET_IID(nsISOAPParameter))) {
*_retval = nsCRT::strdup(kAllAccess);
}
return NS_OK;
}
/* string canSetProperty (in nsIIDPtr iid, in wstring propertyName); */
NS_IMETHODIMP
nsSOAPParameter::CanSetProperty(const nsIID * iid, const PRUnichar *propertyName, char **_retval)
{
if (iid->Equals(NS_GET_IID(nsISOAPParameter))) {
*_retval = nsCRT::strdup(kAllAccess);
}
return NS_OK;
}

View File

@@ -0,0 +1,69 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Netscape 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/NPL/
*
* Software distributed under the License is distributed on an "AS
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
* implied. See the License for the specific language governing
* rights and limitations under the License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All
* Rights Reserved.
*
* Contributor(s):
*/
#ifndef nsSOAPParameter_h__
#define nsSOAPParameter_h__
#include "nsString.h"
#include "nsIVariant.h"
#include "nsISOAPParameter.h"
#include "nsISecurityCheckedComponent.h"
#include "nsIJSNativeInitializer.h"
#include "nsISOAPEncoding.h"
#include "nsISchema.h"
#include "nsIDOMElement.h"
#include "nsISOAPAttachments.h"
#include "nsCOMPtr.h"
class nsSOAPParameter : public nsISOAPParameter,
public nsISecurityCheckedComponent,
public nsIJSNativeInitializer
{
public:
nsSOAPParameter();
virtual ~nsSOAPParameter();
NS_DECL_ISUPPORTS
// nsISOAPParameter
NS_DECL_NSISOAPPARAMETER
// nsISecurityCheckedComponent
NS_DECL_NSISECURITYCHECKEDCOMPONENT
// nsIJSNativeInitializer
NS_IMETHOD Initialize(JSContext *cx, JSObject *obj,
PRUint32 argc, jsval *argv);
protected:
nsString mNamespaceURI;
nsString mName;
nsCOMPtr<nsISOAPEncoding> mEncoding;
nsCOMPtr<nsISchemaType> mSchemaType;
nsCOMPtr<nsISOAPAttachments> mAttachments;
nsCOMPtr<nsIDOMElement> mElement;
nsCOMPtr<nsIVariant> mValue;
nsresult mStatus;
PRBool mComputeValue;
};
#endif

View File

@@ -0,0 +1,122 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Netscape 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/NPL/
*
* Software distributed under the License is distributed on an "AS
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
* implied. See the License for the specific language governing
* rights and limitations under the License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All
* Rights Reserved.
*
* Contributor(s):
*/
#include "nsSOAPResponse.h"
#include "nsSOAPUtils.h"
#include "nsSOAPFault.h"
#include "nsISOAPParameter.h"
nsSOAPResponse::nsSOAPResponse()
{
}
nsSOAPResponse::~nsSOAPResponse()
{
/* destructor code */
}
NS_IMPL_ISUPPORTS_INHERITED1(nsSOAPResponse, nsSOAPMessage, nsISOAPResponse)
/* attribute nsISOAPCall respondingTo; */
NS_IMETHODIMP nsSOAPResponse::GetRespondingTo(nsISOAPCall * *aRespondingTo)
{
NS_ENSURE_ARG_POINTER(aRespondingTo);
*aRespondingTo = mRespondingTo;
NS_IF_ADDREF(*aRespondingTo);
return NS_OK;
}
NS_IMETHODIMP nsSOAPResponse::SetRespondingTo(nsISOAPCall * aRespondingTo)
{
mRespondingTo = aRespondingTo;
return NS_OK;
}
/* readonly attribute nsISOAPFault fault; */
NS_IMETHODIMP nsSOAPResponse::GetFault(nsISOAPFault * *aFault)
{
NS_ENSURE_ARG_POINTER(aFault);
nsCOMPtr<nsIDOMElement> body;
*aFault = nsnull;
GetBody(getter_AddRefs(body));
if (body) {
nsSOAPUtils::GetSpecificChildElement(body,
nsSOAPUtils::kSOAPEnvURI, nsSOAPUtils::kFaultTagName,
getter_AddRefs(body));
if (body) {
*aFault = new nsSOAPFault(body);
if (!*aFault)
return NS_ERROR_OUT_OF_MEMORY;
NS_ADDREF(*aFault);
}
}
else {
*aFault = nsnull;
}
return NS_OK;
}
static const char* kAllAccess = "AllAccess";
/* string canCreateWrapper (in nsIIDPtr iid); */
NS_IMETHODIMP
nsSOAPResponse::CanCreateWrapper(const nsIID * iid, char **_retval)
{
if (iid->Equals(NS_GET_IID(nsISOAPResponse))) {
*_retval = nsCRT::strdup(kAllAccess);
}
return NS_OK;
}
/* string canCallMethod (in nsIIDPtr iid, in wstring methodName); */
NS_IMETHODIMP
nsSOAPResponse::CanCallMethod(const nsIID * iid, const PRUnichar *methodName, char **_retval)
{
if (iid->Equals(NS_GET_IID(nsISOAPResponse))) {
*_retval = nsCRT::strdup(kAllAccess);
}
return NS_OK;
}
/* string canGetProperty (in nsIIDPtr iid, in wstring propertyName); */
NS_IMETHODIMP
nsSOAPResponse::CanGetProperty(const nsIID * iid, const PRUnichar *propertyName, char **_retval)
{
if (iid->Equals(NS_GET_IID(nsISOAPResponse))) {
*_retval = nsCRT::strdup(kAllAccess);
}
return NS_OK;
}
/* string canSetProperty (in nsIIDPtr iid, in wstring propertyName); */
NS_IMETHODIMP
nsSOAPResponse::CanSetProperty(const nsIID * iid, const PRUnichar *propertyName, char **_retval)
{
if (iid->Equals(NS_GET_IID(nsISOAPResponse))) {
*_retval = nsCRT::strdup(kAllAccess);
}
return NS_OK;
}

View File

@@ -0,0 +1,56 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Netscape 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/NPL/
*
* Software distributed under the License is distributed on an "AS
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
* implied. See the License for the specific language governing
* rights and limitations under the License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All
* Rights Reserved.
*
* Contributor(s):
*/
#ifndef nsSOAPResponse_h__
#define nsSOAPResponse_h__
#include "nsString.h"
#include "nsSOAPCall.h"
#include "nsISOAPResponse.h"
#include "nsISecurityCheckedComponent.h"
#include "nsIDOMDocument.h"
#include "nsIDOMElement.h"
#include "nsCOMPtr.h"
class nsSOAPResponse : public nsSOAPMessage,
public nsISOAPResponse
{
public:
NS_DECL_ISUPPORTS
// nsISOAPResponse
NS_FORWARD_NSISOAPMESSAGE(nsSOAPMessage::)
// nsISOAPResponse
NS_DECL_NSISOAPRESPONSE
// nsISecurityCheckedComponent
NS_DECL_NSISECURITYCHECKEDCOMPONENT
nsSOAPResponse();
virtual ~nsSOAPResponse();
protected:
nsCOMPtr<nsISOAPCall> mRespondingTo;
};
#endif

View File

@@ -0,0 +1,237 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Netscape 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/NPL/
*
* Software distributed under the License is distributed on an "AS
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
* implied. See the License for the specific language governing
* rights and limitations under the License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All
* Rights Reserved.
*
* Contributor(s):
*/
#include "nsString.h"
#include "nsSOAPStruct.h"
#include "nsSOAPUtils.h"
#include "nsSupportsArray.h"
#include "nsIXPConnect.h"
#include "nsIServiceManager.h"
#include "nsIComponentManager.h"
#include "nsISOAPParameter.h"
#include "nsSOAPJSValue.h"
#include "jsapi.h"
NS_IMPL_ISUPPORTS3(nsSOAPStruct, nsISOAPStruct, nsIXPCScriptable, nsISecurityCheckedComponent)
nsSOAPStruct::nsSOAPStruct(): mMembers(new nsSupportsHashtable)
{
NS_INIT_ISUPPORTS();
/* member initializers and constructor code */
}
nsSOAPStruct::~nsSOAPStruct()
{
/* destructor code */
delete mMembers;
}
class nsSOAPStructEnumerator : public nsISimpleEnumerator
{
public:
NS_DECL_ISUPPORTS
// nsISimpleEnumerator methods:
NS_DECL_NSISIMPLEENUMERATOR
// nsSOAPStructEnumerator methods:
nsSOAPStructEnumerator(nsSOAPStruct* aStruct);
virtual ~nsSOAPStructEnumerator();
protected:
nsCOMPtr<nsSupportsArray> mMembers;
PRUint32 mCurrent;
};
PRBool StructEnumFunc(nsHashKey *aKey, void *aData, void* aClosure)
{
nsISupportsArray* members = NS_STATIC_CAST(nsISupportsArray*,aClosure);
nsISOAPParameter* parameter = NS_STATIC_CAST(nsISOAPParameter*,aData);
members->AppendElement(parameter);
return PR_TRUE;
}
nsSOAPStructEnumerator::nsSOAPStructEnumerator(nsSOAPStruct* aStruct)
: mMembers(new nsSupportsArray()), mCurrent(0)
{
NS_INIT_REFCNT();
aStruct->mMembers->Enumerate(&StructEnumFunc, mMembers);
}
nsSOAPStructEnumerator::~nsSOAPStructEnumerator()
{
}
NS_IMPL_ISUPPORTS1(nsSOAPStructEnumerator, nsISimpleEnumerator)
NS_IMETHODIMP nsSOAPStructEnumerator::GetNext(nsISupports** aItem)
{
NS_ENSURE_ARG_POINTER(aItem);
PRUint32 count;
mMembers->Count(&count);
if (mCurrent < count) {
*aItem = mMembers->ElementAt(mCurrent++);
return NS_OK;
}
return NS_ERROR_FAILURE;
}
NS_IMETHODIMP nsSOAPStructEnumerator::HasMoreElements(PRBool* aResult)
{
NS_ENSURE_ARG_POINTER(aResult);
PRUint32 count;
mMembers->Count(&count);
*aResult = mCurrent < count;
return NS_OK;
}
/* readonly attribute nsISimpleEnumerator members; */
NS_IMETHODIMP nsSOAPStruct::GetMembers(nsISimpleEnumerator * *aMembers)
{
NS_ENSURE_ARG_POINTER(aMembers);
*aMembers = new nsSOAPStructEnumerator(this);
if (aMembers) {
NS_ADDREF(*aMembers);
return NS_OK;
}
return NS_ERROR_OUT_OF_MEMORY;
}
NS_IMETHODIMP nsSOAPStruct::GetMember(const nsAReadableString& aName, nsISOAPParameter* *aMember)
{
NS_ENSURE_ARG_POINTER(aMember);
nsStringKey nameKey(aName);
*aMember = NS_STATIC_CAST(nsISOAPParameter*, mMembers->Get(&nameKey));
return NS_OK;
}
// The nsIXPCScriptable map declaration that will generate stubs for us...
#define XPC_MAP_CLASSNAME nsSOAPStruct
#define XPC_MAP_QUOTED_CLASSNAME "SOAPStruct"
#define XPC_MAP_WANT_SETPROPERTY
#define XPC_MAP_WANT_GETPROPERTY
#define XPC_MAP_FLAGS nsIXPCScriptable::USE_JSSTUB_FOR_ADDPROPERTY | \
nsIXPCScriptable::USE_JSSTUB_FOR_DELPROPERTY | \
nsIXPCScriptable::USE_JSSTUB_FOR_SETPROPERTY
#include "xpc_map_end.h" /* This will #undef the above */
NS_IMETHODIMP
nsSOAPStruct::GetProperty(nsIXPConnectWrappedNative *wrapper, JSContext *cx,
JSObject *obj, jsval id, jsval *vp,
PRBool *_retval)
{
if (JSVAL_IS_STRING(id)) {
JSString* str = JSVAL_TO_STRING(id);
const PRUnichar* name = NS_REINTERPRET_CAST(const PRUnichar *,
JS_GetStringChars(str));
nsDependentString namestr(name);
nsStringKey nameKey(namestr);
nsCOMPtr<nsISOAPParameter> parameter = dont_AddRef(NS_STATIC_CAST(nsISOAPParameter*, mMembers->Get(&nameKey)));
if (parameter == nsnull)
return NS_OK;
nsAutoString type;
parameter->GetType(type);
nsCOMPtr<nsISupports> value;
parameter->GetValue(getter_AddRefs(value));
return nsSOAPJSValue::ConvertValueToJSVal(cx,
value,
type,
vp);
}
return NS_OK;
}
NS_IMETHODIMP
nsSOAPStruct::SetProperty(nsIXPConnectWrappedNative *wrapper, JSContext *cx,
JSObject *obj, jsval id, jsval *vp,
PRBool *_retval)
{
if (JSVAL_IS_STRING(id)) {
JSString* str = JSVAL_TO_STRING(id);
const PRUnichar* name = NS_REINTERPRET_CAST(const PRUnichar *,
JS_GetStringChars(str));
nsDependentString namestr(name);
nsStringKey nameKey(namestr);
nsCOMPtr<nsISupports> value;
nsAutoString type;
nsresult rc = nsSOAPJSValue::ConvertJSValToValue(cx,
*vp,
getter_AddRefs(value),
type);
if (NS_FAILED(rc))
return rc;
nsCOMPtr<nsISOAPParameter> parameter = do_CreateInstance(NS_SOAPPARAMETER_CONTRACTID);
parameter->SetName(namestr);
parameter->SetValue(value);
parameter->SetType(type);
mMembers->Put(&nameKey, parameter);
}
return NS_OK;
}
static const char* kAllAccess = "AllAccess";
/* string canCreateWrapper (in nsIIDPtr iid); */
NS_IMETHODIMP
nsSOAPStruct::CanCreateWrapper(const nsIID * iid, char **_retval)
{
if (iid->Equals(NS_GET_IID(nsISOAPStruct))) {
*_retval = nsCRT::strdup(kAllAccess);
}
return NS_OK;
}
/* string canCallMethod (in nsIIDPtr iid, in wstring methodName); */
NS_IMETHODIMP
nsSOAPStruct::CanCallMethod(const nsIID * iid, const PRUnichar *methodName, char **_retval)
{
if (iid->Equals(NS_GET_IID(nsISOAPStruct))) {
*_retval = nsCRT::strdup(kAllAccess);
}
return NS_OK;
}
/* string canGetProperty (in nsIIDPtr iid, in wstring propertyName); */
NS_IMETHODIMP
nsSOAPStruct::CanGetProperty(const nsIID * iid, const PRUnichar *propertyName, char **_retval)
{
if (iid->Equals(NS_GET_IID(nsISOAPStruct))) {
*_retval = nsCRT::strdup(kAllAccess);
}
return NS_OK;
}
/* string canSetProperty (in nsIIDPtr iid, in wstring propertyName); */
NS_IMETHODIMP
nsSOAPStruct::CanSetProperty(const nsIID * iid, const PRUnichar *propertyName, char **_retval)
{
if (iid->Equals(NS_GET_IID(nsISOAPStruct))) {
*_retval = nsCRT::strdup(kAllAccess);
}
return NS_OK;
}

View File

@@ -0,0 +1,62 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Netscape 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/NPL/
*
* Software distributed under the License is distributed on an "AS
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
* implied. See the License for the specific language governing
* rights and limitations under the License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All
* Rights Reserved.
*
* Contributor(s):
*/
#ifndef nsSOAPStruct_h__
#define nsSOAPStruct_h__
#include "nsString.h"
#include "nsISOAPStruct.h"
#include "nsIXPCScriptable.h"
#include "nsISecurityCheckedComponent.h"
#include "nsCOMPtr.h"
#include "nsHashtable.h"
class nsSOAPStructEnumerator;
class nsSOAPStruct : public nsISOAPStruct,
public nsIXPCScriptable,
public nsISecurityCheckedComponent
{
public:
nsSOAPStruct();
virtual ~nsSOAPStruct();
NS_DECL_ISUPPORTS
// nsISOAPStruct
NS_DECL_NSISOAPSTRUCT
// nsISOAPStruct
NS_DECL_NSIXPCSCRIPTABLE
// nsISecurityCheckedComponent
NS_DECL_NSISECURITYCHECKEDCOMPONENT
nsresult SetMember(nsISOAPParameter *member);
protected:
nsSupportsHashtable* mMembers;
friend nsSOAPStructEnumerator;
};
#endif

View File

@@ -0,0 +1,426 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Netscape 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/NPL/
*
* Software distributed under the License is distributed on an "AS
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
* implied. See the License for the specific language governing
* rights and limitations under the License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All
* Rights Reserved.
*
* Contributor(s):
*/
#include "nsSOAPUtils.h"
#include "nsIDOMText.h"
#include "nsIDOMNamedNodeMap.h"
#include "nsCOMPtr.h"
NS_NAMED_LITERAL_STRING(nsSOAPUtils::kSOAPEnvURI,"http://schemas.xmlsoap.org/soap/envelope/");
NS_NAMED_LITERAL_STRING(nsSOAPUtils::kSOAPEncodingURI,"http://schemas.xmlsoap.org/soap/encoding/");
NS_NAMED_LITERAL_STRING(nsSOAPUtils::kSOAPEnvPrefix,"SOAP-ENV");
NS_NAMED_LITERAL_STRING(nsSOAPUtils::kSOAPEncodingPrefix,"SOAP-ENC");
NS_NAMED_LITERAL_STRING(nsSOAPUtils::kXSIURI,"http://www.w3.org/1999/XMLSchema-instance");
NS_NAMED_LITERAL_STRING(nsSOAPUtils::kXSDURI,"http://www.w3.org/1999/XMLSchema");
NS_NAMED_LITERAL_STRING(nsSOAPUtils::kXSIPrefix,"xsi");
NS_NAMED_LITERAL_STRING(nsSOAPUtils::kXSITypeAttribute,"type");
NS_NAMED_LITERAL_STRING(nsSOAPUtils::kXSDPrefix,"xsd");
NS_NAMED_LITERAL_STRING(nsSOAPUtils::kEncodingStyleAttribute,"encodingStyle");
NS_NAMED_LITERAL_STRING(nsSOAPUtils::kActorAttribute,"actor");
NS_NAMED_LITERAL_STRING(nsSOAPUtils::kEnvelopeTagName,"Envelope");
NS_NAMED_LITERAL_STRING(nsSOAPUtils::kHeaderTagName,"Header");
NS_NAMED_LITERAL_STRING(nsSOAPUtils::kBodyTagName,"Body");
NS_NAMED_LITERAL_STRING(nsSOAPUtils::kFaultTagName,"Fault");
NS_NAMED_LITERAL_STRING(nsSOAPUtils::kFaultCodeTagName,"faultcode");
NS_NAMED_LITERAL_STRING(nsSOAPUtils::kFaultStringTagName,"faultstring");
NS_NAMED_LITERAL_STRING(nsSOAPUtils::kFaultActorTagName,"faultactor");
NS_NAMED_LITERAL_STRING(nsSOAPUtils::kFaultDetailTagName,"detail");
NS_NAMED_LITERAL_STRING(nsSOAPUtils::kEncodingSeparator,"#");
NS_NAMED_LITERAL_STRING(nsSOAPUtils::kQualifiedSeparator,":");
NS_NAMED_LITERAL_STRING(nsSOAPUtils::kXMLNamespaceNamespaceURI, "htp://www.w3.org/2000/xmlns/");
NS_NAMED_LITERAL_STRING(nsSOAPUtils::kXMLNamespaceURI, "htp://www.w3.org/XML/1998/namespace");
NS_NAMED_LITERAL_STRING(nsSOAPUtils::kXMLPrefix, "xml:");
NS_NAMED_LITERAL_STRING(nsSOAPUtils::kXMLNamespacePrefix, "xmlns:");
void
nsSOAPUtils::GetSpecificChildElement(
nsIDOMElement *aParent,
const nsAReadableString& aNamespace,
const nsAReadableString& aType,
nsIDOMElement * *aElement)
{
nsCOMPtr<nsIDOMElement> sibling;
*aElement = nsnull;
GetFirstChildElement(aParent, getter_AddRefs(sibling));
if (sibling)
{
GetSpecificSiblingElement(sibling,
aNamespace, aType, aElement);
}
}
void
nsSOAPUtils::GetSpecificSiblingElement(
nsIDOMElement *aSibling,
const nsAReadableString& aNamespace,
const nsAReadableString& aType,
nsIDOMElement * *aElement)
{
nsCOMPtr<nsIDOMElement> sibling;
*aElement = nsnull;
sibling = aSibling;
do {
nsAutoString name, namespaceURI;
sibling->GetLocalName(name);
sibling->GetNamespaceURI(namespaceURI);
if (name.Equals(aType)
&& namespaceURI.Equals(nsSOAPUtils::kSOAPEnvURI))
{
*aElement = sibling;
NS_ADDREF(*aElement);
return;
}
nsCOMPtr<nsIDOMElement> temp = sibling;
GetNextSiblingElement(temp, getter_AddRefs(sibling));
} while (sibling);
}
void
nsSOAPUtils::GetFirstChildElement(nsIDOMElement* aParent,
nsIDOMElement** aElement)
{
nsCOMPtr<nsIDOMNode> child;
*aElement = nsnull;
aParent->GetFirstChild(getter_AddRefs(child));
while (child) {
PRUint16 type;
child->GetNodeType(&type);
if (nsIDOMNode::ELEMENT_NODE == type) {
child->QueryInterface(NS_GET_IID(nsIDOMElement), (void**)aElement);
break;
}
nsCOMPtr<nsIDOMNode> temp = child;
GetNextSibling(temp, getter_AddRefs(child));
}
}
void
nsSOAPUtils::GetNextSiblingElement(nsIDOMElement* aStart,
nsIDOMElement** aElement)
{
nsCOMPtr<nsIDOMNode> sibling;
*aElement = nsnull;
GetNextSibling(aStart, getter_AddRefs(sibling));
while (sibling) {
PRUint16 type;
sibling->GetNodeType(&type);
if (nsIDOMNode::ELEMENT_NODE == type) {
sibling->QueryInterface(NS_GET_IID(nsIDOMElement), (void**)aElement);
break;
}
nsCOMPtr<nsIDOMNode> temp = sibling;
GetNextSibling(temp, getter_AddRefs(sibling));
}
}
nsresult
nsSOAPUtils::GetElementTextContent(nsIDOMElement* aElement,
nsAWritableString& aText)
{
nsCOMPtr<nsIDOMNode> child;
nsAutoString rtext;
aElement->GetFirstChild(getter_AddRefs(child));
while (child) {
PRUint16 type;
child->GetNodeType(&type);
if (nsIDOMNode::TEXT_NODE == type
|| nsIDOMNode::CDATA_SECTION_NODE == type) {
nsCOMPtr<nsIDOMText> text = do_QueryInterface(child);
nsAutoString data;
text->GetData(data);
rtext.Append(data);
}
else if (nsIDOMNode::ELEMENT_NODE == type) {
return NS_ERROR_ILLEGAL_VALUE; // This was interpreted as a simple value, yet had complex content in it.
}
nsCOMPtr<nsIDOMNode> temp = child;
GetNextSibling(temp, getter_AddRefs(child));
}
aText.Assign(rtext);
return NS_OK;
}
PRBool
nsSOAPUtils::HasChildElements(nsIDOMElement* aElement)
{
nsCOMPtr<nsIDOMNode> child;
aElement->GetFirstChild(getter_AddRefs(child));
while (child) {
PRUint16 type;
child->GetNodeType(&type);
if (nsIDOMNode::ELEMENT_NODE == type) {
return PR_TRUE;
}
nsCOMPtr<nsIDOMNode> temp = child;
GetNextSibling(temp, getter_AddRefs(child));
}
return PR_FALSE;
}
void
nsSOAPUtils::GetNextSibling(nsIDOMNode* aSibling, nsIDOMNode **aNext)
{
nsCOMPtr<nsIDOMNode> last;
nsCOMPtr<nsIDOMNode> current;
PRUint16 type;
*aNext = nsnull;
last = aSibling;
last->GetNodeType(&type);
if (nsIDOMNode::ENTITY_REFERENCE_NODE == type) {
last->GetFirstChild(getter_AddRefs(current));
if (!last)
{
last->GetNextSibling(getter_AddRefs(current));
}
}
else {
last->GetNextSibling(getter_AddRefs(current));
}
while (!current)
{
last->GetParentNode(getter_AddRefs(current));
current->GetNodeType(&type);
if (nsIDOMNode::ENTITY_REFERENCE_NODE == type) {
last = current;
last->GetNextSibling(getter_AddRefs(current));
}
else {
current = nsnull;
break;
}
}
*aNext = current;
NS_IF_ADDREF(*aNext);
}
nsresult nsSOAPUtils::GetNamespaceURI(nsIDOMElement* aScope,
const nsAReadableString & aQName,
nsAWritableString & aURI)
{
aURI.Truncate(0);
PRInt32 i = aQName.FindChar(':');
if (i < 0) {
return NS_OK;
}
nsAutoString prefix;
aQName.Left(prefix, i);
if (prefix.Equals(kXMLPrefix)) {
aURI.Assign(kXMLNamespaceURI);
return NS_OK;
}
nsresult rc;
nsCOMPtr<nsIDOMNode> current = aScope;
nsCOMPtr<nsIDOMNamedNodeMap> attrs;
nsCOMPtr<nsIDOMNode> temp;
nsAutoString value;
while (current != nsnull) {
rc = current->GetAttributes(getter_AddRefs(attrs));
if (NS_FAILED(rc)) return rc;
if (attrs) {
rc = attrs->GetNamedItemNS(kXMLNamespaceNamespaceURI, prefix, getter_AddRefs(temp));
if (NS_FAILED(rc)) return rc;
if (temp != nsnull)
return temp->GetNodeValue(aURI);
}
rc = current->GetParentNode(getter_AddRefs(temp));
if (NS_FAILED(rc)) return rc;
current = temp;
}
return NS_ERROR_FAILURE;
}
nsresult nsSOAPUtils::GetLocalName(const nsAReadableString & aQName,
nsAWritableString & aLocalName)
{
PRInt32 i = aQName.FindChar(':');
if (i < 0)
aLocalName = aQName;
else
aQName.Mid(aLocalName, i, aQName.Length() - i);
return NS_OK;
}
nsresult
nsSOAPUtils::MakeNamespacePrefix(nsIDOMElement* aScope,
const nsAReadableString & aURI,
nsAWritableString & aPrefix)
{
// This may change for level 3 serialization, so be sure to gut this
// and call the standardized level 3 method when it is available.
aPrefix.Truncate(0);
if (aURI.IsEmpty())
return NS_OK;
if (aURI.Equals(nsSOAPUtils::kXMLNamespaceURI)) {
aPrefix.Assign(nsSOAPUtils::kXMLPrefix);
return NS_OK;
}
nsCOMPtr<nsIDOMNode> current = aScope;
nsCOMPtr<nsIDOMNamedNodeMap> attrs;
nsCOMPtr<nsIDOMNode> temp;
nsAutoString tstr;
nsresult rc;
PRUint32 maxns = 0; // Keep track of max generated NS
for (;;) {
rc = current->GetAttributes(getter_AddRefs(attrs));
if (NS_FAILED(rc)) return rc;
if (attrs) {
PRUint32 i = 0;
for (;;)
{
attrs->Item(i++, getter_AddRefs(temp));
if (!temp)
break;
temp->GetNamespaceURI(tstr);
if (!tstr.Equals(nsSOAPUtils::kXMLNamespaceNamespaceURI))
continue;
temp->GetNodeValue(tstr);
if (tstr.Equals(aURI)) {
nsAutoString prefix;
rc = temp->GetLocalName(prefix);
if (NS_FAILED(rc)) return rc;
nsCOMPtr<nsIDOMNode> check = aScope;
PRBool hasDecl;
nsCOMPtr<nsIDOMElement> echeck;
while (check != current) { // Make sure prefix is not overridden
echeck = do_QueryInterface(check);
if (echeck) {
rc = echeck->HasAttributeNS(nsSOAPUtils::kXMLNamespaceNamespaceURI, prefix, &hasDecl);
if (NS_FAILED(rc)) return rc;
if (hasDecl)
break;
current->GetParentNode(getter_AddRefs(temp));
current = temp;
}
}
if (check == current) {
aPrefix.Assign(prefix);
return NS_OK;
}
}
rc = temp->GetLocalName(tstr);
if (NS_FAILED(rc))
return rc;
else { // Decode the generated namespace into a number
nsReadingIterator<PRUnichar> i1;
nsReadingIterator<PRUnichar> i2;
tstr.BeginReading(i1);
tstr.EndReading(i2);
if (i1 == i2 || *i1 != 'n')
continue;
i1++;
if (i1 == i2 || *i1 != 's')
continue;
i1++;
PRUint32 n = 0;
while (i1 != i2) {
PRUnichar c = *i1;
i1++;
if (c < '0' || c > '9') {
n = 0;
break;
}
n = n * 10 + (c - '0');
}
if (n > maxns)
maxns = n;
}
}
}
current->GetParentNode(getter_AddRefs(temp));
if (temp)
current = temp;
else
break;
}
// Create a unique prefix...
PRUint32 len = 3;
PRUint32 c = maxns + 1;
while (c >= 10) {
c = c / 10;
len++;
}
// Set the length and write it backwards since that's the easiest way..
aPrefix.SetLength(len);
nsWritingIterator<PRUnichar> i2;
aPrefix.EndWriting(i2);
c = maxns + 1;
while (c > 0) {
PRUint32 r = c % 10;
c = c / 10;
i2--;
*i2 = (PRUnichar)(r + '0');
}
i2--;
*i2 = 's';
i2--;
*i2 = 'n';
return NS_OK;
}
nsresult
nsSOAPUtils::MakeNamespacePrefixFixed(nsIDOMElement* aScope,
const nsAReadableString & aURI,
nsAWritableString & aPrefix)
{
if (aURI.Equals(kSOAPEncodingURI))
aPrefix = kSOAPEncodingPrefix;
else if (aURI.Equals(kSOAPEnvURI))
aPrefix = kSOAPEnvPrefix;
else if (aURI.Equals(kXSIURI))
aPrefix = kXSIPrefix;
else if (aURI.Equals(kXSDURI))
aPrefix = kXSDPrefix;
else
return MakeNamespacePrefix(aScope, aURI, aPrefix);
return NS_OK;
}
PRBool nsSOAPUtils::StartsWith(nsAReadableString& aSuper,
nsAReadableString& aSub)
{
PRUint32 c1 = aSuper.Length();
PRUint32 c2 = aSub.Length();
if (c1 < c2) return PR_FALSE;
if (c1 == c2) return aSuper.Equals(aSub);
nsReadingIterator<PRUnichar> i1;
nsReadingIterator<PRUnichar> i2;
aSuper.BeginReading(i1);
aSub.BeginReading(i2);
while (c2--) {
if (*i1 != *i2) return PR_FALSE;
i1++;
i2++;
}
return PR_TRUE;
}

View File

@@ -0,0 +1,109 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Netscape 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/NPL/
*
* Software distributed under the License is distributed on an "AS
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
* implied. See the License for the specific language governing
* rights and limitations under the License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All
* Rights Reserved.
*
* Contributor(s):
*/
#ifndef nsSOAPUtils_h__
#define nsSOAPUtils_h__
#include "nsString.h"
#include "nsIDOMElement.h"
class nsSOAPUtils {
public:
static void GetSpecificChildElement(nsIDOMElement *aParent,
const nsAReadableString& aNamespace,
const nsAReadableString& aType,
nsIDOMElement * *aElement);
static void GetSpecificSiblingElement(nsIDOMElement *aSibling,
const nsAReadableString& aNamespace,
const nsAReadableString& aType,
nsIDOMElement * *aElement);
static void GetFirstChildElement(nsIDOMElement* aParent,
nsIDOMElement** aElement);
static void GetNextSiblingElement(nsIDOMElement* aStart,
nsIDOMElement** aElement);
static nsresult GetElementTextContent(nsIDOMElement* aElement,
nsAWritableString& aText);
static PRBool HasChildElements(nsIDOMElement* aElement);
static void GetNextSibling(nsIDOMNode* aSibling,
nsIDOMNode **aNext);
static nsresult MakeNamespacePrefix(nsIDOMElement* aElement,
const nsAReadableString & aURI,
nsAWritableString & aPrefix);
static nsresult MakeNamespacePrefixFixed(nsIDOMElement* aElement,
const nsAReadableString & aURI,
nsAWritableString & aPrefix);
static nsresult GetNamespaceURI(nsIDOMElement* aElement,
const nsAReadableString & aQName,
nsAWritableString & aURI);
static nsresult GetLocalName(const nsAReadableString & aQName,
nsAWritableString & aLocalName);
// All those missing string functions have to come from somewhere...
static PRBool StartsWith(nsAReadableString& aSuper,
nsAReadableString& aSub);
static nsDependentString kSOAPEnvURI;
static nsDependentString kSOAPEncodingURI;
static nsDependentString kSOAPEnvPrefix;
static nsDependentString kSOAPEncodingPrefix;
static nsDependentString kXSIURI;
static nsDependentString kXSDURI;
static nsDependentString kXSIPrefix;
static nsDependentString kXSITypeAttribute;
static nsDependentString kXSDPrefix;
static nsDependentString kEncodingStyleAttribute;
static nsDependentString kActorAttribute;
static nsDependentString kEnvelopeTagName;
static nsDependentString kHeaderTagName;
static nsDependentString kBodyTagName;
static nsDependentString kFaultTagName;
static nsDependentString kFaultCodeTagName;
static nsDependentString kFaultStringTagName;
static nsDependentString kFaultActorTagName;
static nsDependentString kFaultDetailTagName;
static nsDependentString kEncodingSeparator;
static nsDependentString kQualifiedSeparator;
static nsDependentString kXMLNamespaceNamespaceURI;
static nsDependentString kXMLNamespaceURI;
static nsDependentString kXMLNamespacePrefix;
static nsDependentString kXMLPrefix;
};
// Used to support null strings.
inline PRBool AStringIsNull(const nsAReadableString& aString)
{
return aString.IsVoid() || aString.IsEmpty(); // Get rid of empty hack when string implementations support.
}
inline void SetAStringToNull(nsAWritableString& aString)
{
aString.Truncate();
aString.SetIsVoid(PR_TRUE);
}
#define NS_SOAP_ENSURE_ARG_STRING(arg) \
NS_ENSURE_FALSE(AStringIsNull(arg), NS_ERROR_INVALID_ARG)
#endif

Binary file not shown.

Before

Width:  |  Height:  |  Size: 82 B

View File

@@ -1,97 +0,0 @@
# -*- Mode: perl; indent-tabs-mode: nil -*-
#
# 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 the Bugzilla Bug Tracking System.
#
# The Initial Developer of the Original Code is Netscape Communications
# Corporation. Portions created by Netscape are
# Copyright (C) 1998 Netscape Communications Corporation. All
# Rights Reserved.
#
# Contributor(s): Terry Weissman <terry@mozilla.org>
# Myk Melez <myk@mozilla.org>
############################################################################
# Module Initialization
############################################################################
use diagnostics;
use strict;
package Attachment;
# This module requires that its caller have said "require CGI.pl" to import
# relevant functions from that script and its companion globals.pl.
############################################################################
# Functions
############################################################################
sub query
{
# Retrieves and returns an array of attachment records for a given bug.
# This data should be given to attachment/list.atml in an
# "attachments" variable.
my ($bugid) = @_;
my $in_editbugs = &::UserInGroup("editbugs");
# Retrieve a list of attachments for this bug and write them into an array
# of hashes in which each hash represents a single attachment.
&::SendSQL("
SELECT attach_id, creation_ts, mimetype, description, ispatch,
isobsolete, submitter_id
FROM attachments WHERE bug_id = $bugid ORDER BY attach_id
");
my @attachments = ();
while (&::MoreSQLData()) {
my %a;
my $submitter_id;
($a{'attachid'}, $a{'date'}, $a{'contenttype'}, $a{'description'},
$a{'ispatch'}, $a{'isobsolete'}, $submitter_id) = &::FetchSQLData();
# Format the attachment's creation/modification date into a standard
# format (YYYY-MM-DD HH:MM)
if ($a{'date'} =~ /^(\d\d\d\d)(\d\d)(\d\d)(\d\d)(\d\d)(\d\d)$/) {
$a{'date'} = "$1-$2-$3 $4:$5";
}
# Retrieve a list of status flags that have been set on the attachment.
&::PushGlobalSQLState();
&::SendSQL("
SELECT name
FROM attachstatuses, attachstatusdefs
WHERE attach_id = $a{'attachid'}
AND attachstatuses.statusid = attachstatusdefs.id
ORDER BY sortkey
");
my @statuses = ();
while (&::MoreSQLData()) {
my ($status) = &::FetchSQLData();
push @statuses , $status;
}
$a{'statuses'} = \@statuses;
&::PopGlobalSQLState();
# We will display the edit link if the user can edit the attachment;
# ie the are the submitter, or they have canedit.
# Also show the link if the user is not logged in - in that cae,
# They'll be prompted later
$a{'canedit'} = ($::userid == 0 || $submitter_id == $::userid ||
$in_editbugs);
push @attachments, \%a;
}
return \@attachments;
}
1;

View File

@@ -1,547 +0,0 @@
# -*- Mode: perl; indent-tabs-mode: nil -*-
#
# 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 the Bugzilla Bug Tracking System.
#
# The Initial Developer of the Original Code is Netscape Communications
# Corporation. Portions created by Netscape are
# Copyright (C) 1998 Netscape Communications Corporation. All
# Rights Reserved.
#
# Contributor(s): Dawn Endico <endico@mozilla.org>
# Terry Weissman <terry@mozilla.org>
# Chris Yeh <cyeh@bluemartini.com>
use diagnostics;
use strict;
use DBI;
use RelationSet;
use vars qw($unconfirmedstate $legal_keywords);
require "globals.pl";
require "CGI.pl";
package Bug;
use CGI::Carp qw(fatalsToBrowser);
my %ok_field;
for my $key (qw (bug_id product version rep_platform op_sys bug_status
resolution priority bug_severity component assigned_to
reporter bug_file_loc short_desc target_milestone
qa_contact status_whiteboard creation_ts groupset
delta_ts votes whoid usergroupset comment query error) ){
$ok_field{$key}++;
}
# create a new empty bug
#
sub new {
my $type = shift();
my %bug;
# create a ref to an empty hash and bless it
#
my $self = {%bug};
bless $self, $type;
# construct from a hash containing a bug's info
#
if ($#_ == 1) {
$self->initBug(@_);
} else {
confess("invalid number of arguments \($#_\)($_)");
}
# bless as a Bug
#
return $self;
}
# dump info about bug into hash unless user doesn't have permission
# user_id 0 is used when person is not logged in.
#
sub initBug {
my $self = shift();
my ($bug_id, $user_id) = (@_);
my $old_bug_id = $bug_id;
if ((! defined $bug_id) || (!$bug_id) || (!&::detaint_natural($bug_id))) {
# no bug number given
$self->{'bug_id'} = $old_bug_id;
$self->{'error'} = "InvalidBugId";
return $self;
}
# default userid 0, or get DBID if you used an email address
unless (defined $user_id) {
$user_id = 0;
}
else {
if ($user_id =~ /^\@/) {
$user_id = &::DBname_to_id($user_id);
}
}
&::ConnectToDatabase();
&::GetVersionTable();
# this verification should already have been done by caller
# my $loginok = quietly_check_login();
$self->{'whoid'} = $user_id;
&::SendSQL("SELECT groupset FROM profiles WHERE userid=$self->{'whoid'}");
my $usergroupset = &::FetchOneColumn();
if (!$usergroupset) { $usergroupset = '0' }
$self->{'usergroupset'} = $usergroupset;
# Check to see if we can see this bug
if (!&::CanSeeBug($bug_id, $user_id, $usergroupset)) {
# Permission denied to see bug
$self->{'bug_id'} = $old_bug_id;
$self->{'error'} = "PermissionDenied";
return $self;
}
my $query = "";
if ($::driver eq 'mysql') {
$query = "
select
bugs.bug_id, product, version, rep_platform, op_sys, bug_status,
resolution, priority, bug_severity, component, assigned_to, reporter,
bug_file_loc, short_desc, target_milestone, qa_contact,
status_whiteboard, date_format(creation_ts,'%Y-%m-%d %H:%i'),
groupset, delta_ts, sum(votes.count)
from bugs left join votes using(bug_id)
where bugs.bug_id = $bug_id
group by bugs.bug_id";
} elsif ($::driver eq 'Pg') {
$query = "
select
bugs.bug_id, product, version, rep_platform, op_sys, bug_status,
resolution, priority, bug_severity, component, assigned_to, reporter,
bug_file_loc, short_desc, target_milestone, qa_contact,
status_whiteboard, creation_ts,
groupset, delta_ts, sum(votes.count)
from bugs left join votes using(bug_id)
where bugs.bug_id = $bug_id
and (bugs.groupset & int8($usergroupset)) = bugs.groupset
group by bugs.bug_id, product, version, rep_platform, op_sys, bug_status,
resolution, priority, bug_severity, component, assigned_to, reporter,
bug_file_loc, short_desc, target_milestone, qa_contact, status_whiteboard,
creation_ts, groupset, delta_ts";
}
&::SendSQL($query);
my @row;
if (@row = &::FetchSQLData()) {
my $count = 0;
my %fields;
foreach my $field ("bug_id", "product", "version", "rep_platform",
"op_sys", "bug_status", "resolution", "priority",
"bug_severity", "component", "assigned_to", "reporter",
"bug_file_loc", "short_desc", "target_milestone",
"qa_contact", "status_whiteboard", "creation_ts",
"groupset", "delta_ts", "votes") {
$fields{$field} = shift @row;
if ($fields{$field}) {
$self->{$field} = $fields{$field};
}
$count++;
}
} else {
&::SendSQL("select groupset from bugs where bug_id = $bug_id");
if (@row = &::FetchSQLData()) {
$self->{'bug_id'} = $bug_id;
$self->{'error'} = "NotPermitted";
return $self;
} else {
$self->{'bug_id'} = $bug_id;
$self->{'error'} = "NotFound";
return $self;
}
}
$self->{'assigned_to'} = &::DBID_to_name($self->{'assigned_to'});
$self->{'reporter'} = &::DBID_to_name($self->{'reporter'});
my $ccSet = new RelationSet;
$ccSet->mergeFromDB("select who from cc where bug_id=$bug_id");
my @cc = $ccSet->toArrayOfStrings();
if (@cc) {
$self->{'cc'} = \@cc;
}
if (&::Param("useqacontact") && (defined $self->{'qa_contact'}) ) {
my $name = $self->{'qa_contact'} > 0 ? &::DBID_to_name($self->{'qa_contact'}) :"";
if ($name) {
$self->{'qa_contact'} = $name;
}
}
if (@::legal_keywords) {
&::SendSQL("SELECT keyworddefs.name
FROM keyworddefs, keywords
WHERE keywords.bug_id = $bug_id
AND keyworddefs.id = keywords.keywordid
ORDER BY keyworddefs.name");
my @list;
while (&::MoreSQLData()) {
push(@list, &::FetchOneColumn());
}
if (@list) {
$self->{'keywords'} = join(', ', @list);
}
}
&::SendSQL("select attach_id, creation_ts, description
from attachments
where bug_id = $bug_id");
my @attachments;
while (&::MoreSQLData()) {
my ($attachid, $date, $desc) = (&::FetchSQLData());
if ($date =~ /^(\d\d)(\d\d)(\d\d)(\d\d)(\d\d)(\d\d)(\d\d)$/) {
$date = "$3/$4/$2 $5:$6";
my %attach;
$attach{'attachid'} = $attachid;
$attach{'date'} = $date;
$attach{'desc'} = $desc;
push @attachments, \%attach;
}
}
if (@attachments) {
$self->{'attachments'} = \@attachments;
}
&::SendSQL("select bug_id, who, bug_when, thetext
from longdescs
where bug_id = $bug_id");
my @longdescs;
while (&::MoreSQLData()) {
my ($bug_id, $who, $bug_when, $thetext) = (&::FetchSQLData());
my %longdesc;
$longdesc{'who'} = $who;
$longdesc{'bug_when'} = $bug_when;
$longdesc{'thetext'} = $thetext;
push @longdescs, \%longdesc;
}
if (@longdescs) {
$self->{'longdescs'} = \@longdescs;
}
if (&::Param("usedependencies")) {
my @depends = EmitDependList("blocked", "dependson", $bug_id);
if ( @depends ) {
$self->{'dependson'} = \@depends;
}
my @blocks = EmitDependList("dependson", "blocked", $bug_id);
if ( @blocks ) {
$self->{'blocks'} = \@blocks;
}
}
return $self;
}
# given a bug hash, emit xml for it. with file header provided by caller
#
sub emitXML {
( $#_ == 0 ) || confess("invalid number of arguments");
my $self = shift();
my $xml;
if (exists $self->{'error'}) {
$xml .= "<bug error=\"$self->{'error'}\">\n";
$xml .= " <bug_id>$self->{'bug_id'}</bug_id>\n";
$xml .= "</bug>\n";
return $xml;
}
$xml .= "<bug>\n";
foreach my $field ("bug_id", "bug_status", "product",
"priority", "version", "rep_platform", "assigned_to", "delta_ts",
"component", "reporter", "target_milestone", "bug_severity",
"creation_ts", "qa_contact", "op_sys", "resolution", "bug_file_loc",
"short_desc", "keywords", "status_whiteboard") {
if ($self->{$field}) {
$xml .= " <$field>" . QuoteXMLChars($self->{$field}) . "</$field>\n";
}
}
foreach my $field ("dependson", "blocks", "cc") {
if (defined $self->{$field}) {
for (my $i=0 ; $i < @{$self->{$field}} ; $i++) {
$xml .= " <$field>" . $self->{$field}[$i] . "</$field>\n";
}
}
}
if (defined $self->{'longdescs'}) {
for (my $i=0 ; $i < @{$self->{'longdescs'}} ; $i++) {
$xml .= " <long_desc>\n";
$xml .= " <who>" . &::DBID_to_name($self->{'longdescs'}[$i]->{'who'})
. "</who>\n";
$xml .= " <bug_when>" . $self->{'longdescs'}[$i]->{'bug_when'}
. "</bug_when>\n";
$xml .= " <thetext>" . QuoteXMLChars($self->{'longdescs'}[$i]->{'thetext'})
. "</thetext>\n";
$xml .= " </long_desc>\n";
}
}
if (defined $self->{'attachments'}) {
for (my $i=0 ; $i < @{$self->{'attachments'}} ; $i++) {
$xml .= " <attachment>\n";
$xml .= " <attachid>" . $self->{'attachments'}[$i]->{'attachid'}
. "</attachid>\n";
$xml .= " <date>" . $self->{'attachments'}[$i]->{'date'} . "</date>\n";
$xml .= " <desc>" . QuoteXMLChars($self->{'attachments'}[$i]->{'desc'}) . "</desc>\n";
# $xml .= " <type>" . $self->{'attachments'}[$i]->{'type'} . "</type>\n";
# $xml .= " <data>" . $self->{'attachments'}[$i]->{'data'} . "</data>\n";
$xml .= " </attachment>\n";
}
}
$xml .= "</bug>\n";
return $xml;
}
sub EmitDependList {
my ($myfield, $targetfield, $bug_id) = (@_);
my @list;
&::SendSQL("select dependencies.$targetfield, bugs.bug_status
from dependencies, bugs
where dependencies.$myfield = $bug_id
and bugs.bug_id = dependencies.$targetfield
order by dependencies.$targetfield");
while (&::MoreSQLData()) {
my ($i, $stat) = (&::FetchSQLData());
push @list, $i;
}
return @list;
}
sub QuoteXMLChars {
$_[0] =~ s/&/&amp;/g;
$_[0] =~ s/</&lt;/g;
$_[0] =~ s/>/&gt;/g;
$_[0] =~ s/'/&apos;/g;
$_[0] =~ s/"/&quot;/g;
# $_[0] =~ s/([\x80-\xFF])/&XmlUtf8Encode(ord($1))/ge;
return($_[0]);
}
sub XML_Header {
my ($urlbase, $version, $maintainer, $exporter) = (@_);
my $xml;
$xml = "<?xml version=\"1.0\" standalone=\"yes\"?>\n";
$xml .= "<!DOCTYPE bugzilla SYSTEM \"$urlbase";
if (! ($urlbase =~ /.+\/$/)) {
$xml .= "/";
}
$xml .= "bugzilla.dtd\">\n";
$xml .= "<bugzilla";
if (defined $exporter) {
$xml .= " exporter=\"$exporter\"";
}
$xml .= " version=\"$version\"";
$xml .= " urlbase=\"$urlbase\"";
$xml .= " maintainer=\"$maintainer\">\n";
return ($xml);
}
sub XML_Footer {
return ("</bugzilla>\n");
}
sub UserInGroup {
my $self = shift();
my ($groupname) = (@_);
if ($self->{'usergroupset'} eq "0") {
return 0;
}
&::ConnectToDatabase();
&::SendSQL("select (group_bit & int8($self->{'usergroupset'})) != 0 from groups where name = "
. &::SqlQuote($groupname));
my $bit = &::FetchOneColumn();
if ($bit) {
return 1;
}
return 0;
}
sub CanChangeField {
my $self = shift();
my ($f, $oldvalue, $newvalue) = (@_);
my $UserInEditGroupSet = -1;
my $UserInCanConfirmGroupSet = -1;
my $ownerid;
my $reporterid;
my $qacontactid;
if ($f eq "assigned_to" || $f eq "reporter" || $f eq "qa_contact") {
if ($oldvalue =~ /^\d+$/) {
if ($oldvalue == 0) {
$oldvalue = "";
} else {
$oldvalue = &::DBID_to_name($oldvalue);
}
}
}
if ($oldvalue eq $newvalue) {
return 1;
}
if (&::trim($oldvalue) eq &::trim($newvalue)) {
return 1;
}
if ($f =~ /^longdesc/) {
return 1;
}
if ($UserInEditGroupSet < 0) {
$UserInEditGroupSet = UserInGroup($self, "editbugs");
}
if ($UserInEditGroupSet) {
return 1;
}
&::SendSQL("SELECT reporter, assigned_to, qa_contact FROM bugs " .
"WHERE bug_id = $self->{'bug_id'}");
($reporterid, $ownerid, $qacontactid) = (&::FetchSQLData());
# Let reporter change bug status, even if they can't edit bugs.
# If reporter can't re-open their bug they will just file a duplicate.
# While we're at it, let them close their own bugs as well.
if ( ($f eq "bug_status") && ($self->{'whoid'} eq $reporterid) ) {
return 1;
}
if ($f eq "bug_status" && $newvalue ne $::unconfirmedstate &&
&::IsOpenedState($newvalue)) {
# Hmm. They are trying to set this bug to some opened state
# that isn't the UNCONFIRMED state. Are they in the right
# group? Or, has it ever been confirmed? If not, then this
# isn't legal.
if ($UserInCanConfirmGroupSet < 0) {
$UserInCanConfirmGroupSet = &::UserInGroup("canconfirm");
}
if ($UserInCanConfirmGroupSet) {
return 1;
}
&::SendSQL("SELECT everconfirmed FROM bugs WHERE bug_id = $self->{'bug_id'}");
my $everconfirmed = FetchOneColumn();
if ($everconfirmed) {
return 1;
}
} elsif ($reporterid eq $self->{'whoid'} || $ownerid eq $self->{'whoid'} ||
$qacontactid eq $self->{'whoid'}) {
return 1;
}
$self->{'error'} = "
Only the owner or submitter of the bug, or a sufficiently
empowered user, may make that change to the $f field."
}
sub Collision {
my $self = shift();
my $write = "WRITE"; # Might want to make a param to control
# whether we do LOW_PRIORITY ...
if ($::driver eq 'mysql') {
&::SendSQL("LOCK TABLES bugs $write, bugs_activity $write, cc $write, " .
"cc AS selectVisible_cc $write, " .
"profiles $write, dependencies $write, votes $write, " .
"keywords $write, longdescs $write, fielddefs $write, " .
"keyworddefs READ, groups READ, attachments READ, products READ");
}
&::SendSQL("SELECT delta_ts FROM bugs where bug_id=$self->{'bug_id'}");
my $delta_ts = &::FetchOneColumn();
if ($::driver eq 'mysql') {
&::SendSQL("unlock tables");
}
if ($self->{'delta_ts'} ne $delta_ts) {
return 1;
}
else {
return 0;
}
}
sub AppendComment {
my $self = shift();
my ($comment) = (@_);
$comment =~ s/\r\n/\n/g; # Get rid of windows-style line endings.
$comment =~ s/\r/\n/g; # Get rid of mac-style line endings.
if ($comment =~ /^\s*$/) { # Nothin' but whitespace.
return;
}
&::SendSQL("INSERT INTO longdescs (bug_id, who, bug_when, thetext) " .
"VALUES($self->{'bug_id'}, $self->{'whoid'}, now(), " . &::SqlQuote($comment) . ")");
&::SendSQL("UPDATE bugs SET delta_ts = now() WHERE bug_id = $self->{'bug_id'}");
}
#from o'reilley's Programming Perl
sub display {
my $self = shift;
my @keys;
if (@_ == 0) { # no further arguments
@keys = sort keys(%$self);
} else {
@keys = @_; # use the ones given
}
foreach my $key (@keys) {
print "\t$key => $self->{$key}\n";
}
}
sub CommitChanges {
#snapshot bug
#snapshot dependencies
#check can change fields
#check collision
#lock and change fields
#notify through mail
}
sub AUTOLOAD {
use vars qw($AUTOLOAD);
my $self = shift;
my $type = ref($self) || $self;
my $attr = $AUTOLOAD;
$attr =~ s/.*:://;
return unless $attr=~ /[^A-Z]/;
if (@_) {
$self->{$attr} = shift;
return;
}
confess ("invalid bug attribute $attr") unless $ok_field{$attr};
if (defined $self->{$attr}) {
return $self->{$attr};
} else {
return '';
}
}
1;

File diff suppressed because it is too large Load Diff

View File

@@ -1,16 +0,0 @@
* This README is no longer used to house installation instructions. Instead,
it contains pointers to where you may find the information you need.
* Installation instructions are now found in docs/, with a variety of document
types available. Please refer to these documents when installing, configuring,
and maintaining your Bugzilla installation. A helpful starting point is
docs/txt/Bugzilla-Guide.txt, or with a web browser at docs/html/index.html.
* Release notes for people upgrading to a new version of Bugzilla are
available at docs/rel_notes.txt.
* If you wish to contribute to the documentation, please read docs/README.docs.
* The Bugzilla web site is at "http://www.mozilla.org/projects/bugzilla/".
This site will contain the latest Bugzilla information, including how to
report bugs and how to get help with Bugzilla.

View File

@@ -1,268 +0,0 @@
#
# 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 the Bugzilla Bug Tracking System.
#
# The Initial Developer of the Original Code is Netscape Communications
# Corporation. Portions created by Netscape are
# Copyright (C) 2000 Netscape Communications Corporation. All
# Rights Reserved.
#
# Contributor(s): Dan Mosedale <dmose@mozilla.org>
# Terry Weissman <terry@mozilla.org>
# Dave Miller <justdave@syndicomm.com>
# This object models a set of relations between one item and a group
# of other items. An example is the set of relations between one bug
# and the users CCed on that bug. Currently, the relation objects are
# expected to be bugzilla userids. However, this could and perhaps
# should be generalized to work with non userid objects, such as
# keywords associated with a bug. That shouldn't be hard to do; it
# might involve turning this into a virtual base class, and having
# UserSet and KeywordSet types that inherit from it.
use diagnostics;
use strict;
# Everything that uses RelationSet should already have globals.pl loaded
# so we don't want to load it here. Doing so causes a loop in Perl because
# globals.pl turns around and does a 'use RelationSet'
# See http://bugzilla.mozilla.org/show_bug.cgi?id=72862
#require "globals.pl";
package RelationSet;
use CGI::Carp qw(fatalsToBrowser);
# create a new empty RelationSet
#
sub new {
my $type = shift();
# create a ref to an empty hash and bless it
#
my $self = {};
bless $self, $type;
# construct from a comma-delimited string
#
if ($#_ == 0) {
$self->mergeFromString($_[0]);
}
# unless this was a constructor for an empty list, somebody screwed up.
#
elsif ( $#_ != -1 ) {
confess("invalid number of arguments");
}
# bless as a RelationSet
#
return $self;
}
# Assumes that the set of relations "FROM $table WHERE $constantSql and
# $column = $value" is currently represented by $self, and this set should
# be updated to look like $other.
#
# Returns an array of two strings, one INSERT and one DELETE, which will
# make this change. Either or both strings may be the empty string,
# meaning that no INSERT or DELETE or both (respectively) need to be done.
#
# THE CALLER IS RESPONSIBLE FOR ANY DESIRED LOCKING AND/OR CONSISTENCY
# CHECKS (not to mention doing the SendSQL() calls).
#
sub generateSqlDeltas {
($#_ == 5) || confess("invalid number of arguments");
my ( $self, # instance ptr to set representing the existing state
$endState, # instance ptr to set representing the desired state
$table, # table where these relations are kept
$invariantName, # column held const for a RelationSet (often "bug_id")
$invariantValue, # what to hold the above column constant at
$columnName # the column which varies (often a userid)
) = @_;
# construct the insert list by finding relations which exist in the
# end state but not the current state.
#
my @endStateRelations = keys(%$endState);
my @insertList = ();
foreach ( @endStateRelations ) {
push ( @insertList, $_ ) if ( ! exists $$self{"$_"} );
}
# we've built the list. If it's non-null, add required sql chrome.
#
my $sqlInsert="";
if ( $#insertList > -1 ) {
$sqlInsert = "INSERT INTO $table ($invariantName, $columnName) VALUES " .
join (",",
map ( "($invariantValue, $_)" , @insertList )
);
}
# construct the delete list by seeing which relations exist in the
# current state but not the end state
#
my @selfRelations = keys(%$self);
my @deleteList = ();
foreach ( @selfRelations ) {
push (@deleteList, $_) if ( ! exists $$endState{"$_"} );
}
# we've built the list. if it's non-empty, add required sql chrome.
#
my $sqlDelete = "";
if ( $#deleteList > -1 ) {
$sqlDelete = "DELETE FROM $table WHERE $invariantName = $invariantValue " .
"AND $columnName IN ( " . join (",", @deleteList) . " )";
}
return ($sqlInsert, $sqlDelete);
}
# compare the current object with another.
#
sub isEqual {
($#_ == 1) || confess("invalid number of arguments");
my $self = shift();
my $other = shift();
# get arrays of the keys for faster processing
#
my @selfRelations = keys(%$self);
my @otherRelations = keys(%$other);
# make sure the arrays are the same size
#
return 0 if ( $#selfRelations != $#otherRelations );
# bail out if any of the elements are different
#
foreach my $relation ( @selfRelations ) {
return 0 if ( !exists $$other{$relation})
}
# we made it!
#
return 1;
}
# merge the results of a SQL command into this set
#
sub mergeFromDB {
( $#_ == 1 ) || confess("invalid number of arguments");
my $self = shift();
&::SendSQL(shift());
while (my @row = &::FetchSQLData()) {
$$self{$row[0]} = 1;
}
return;
}
# merge a set in string form into this set
#
sub mergeFromString {
($#_ == 1) || confess("invalid number of arguments");
my $self = shift();
# do the merge
#
foreach my $person (split(/[ ,]/, shift())) {
if ($person ne "") {
$$self{&::DBNameToIdAndCheck($person)} = 1;
}
}
}
# remove a set in string form from this set
#
sub removeItemsInString {
($#_ == 1) || confess("invalid number of arguments");
my $self = shift();
# do the merge
#
foreach my $person (split(/[ ,]/, shift())) {
if ($person ne "") {
my $dbid = &::DBNameToIdAndCheck($person);
if (exists $$self{$dbid}) {
delete $$self{$dbid};
}
}
}
}
# remove a set in array form from this set
#
sub removeItemsInArray {
($#_ > 0) || confess("invalid number of arguments");
my $self = shift();
# do the merge
#
while (my $person = shift()) {
if ($person ne "") {
my $dbid = &::DBNameToIdAndCheck($person);
if (exists $$self{$dbid}) {
delete $$self{$dbid};
}
}
}
}
# return the number of elements in this set
#
sub size {
my $self = shift();
my @k = keys(%$self);
return $#k++;
}
# return this set in array form
#
sub toArray {
my $self= shift();
return keys(%$self);
}
# return this set as an array of strings
#
sub toArrayOfStrings {
($#_ == 0) || confess("invalid number of arguments");
my $self = shift();
my @result = ();
foreach my $i ( keys %$self ) {
push @result, &::DBID_to_name($i);
}
return sort { lc($a) cmp lc($b) } @result;
}
# return this set in string form (comma-separated and sorted)
#
sub toString {
($#_ == 0) || confess("invalid number of arguments");
my $self = shift();
my @result = ();
foreach my $i ( keys %$self ) {
push @result, &::DBID_to_name($i);
}
return join(',', sort(@result));
}
1;

View File

@@ -1,273 +0,0 @@
# -*- Mode: perl; indent-tabs-mode: nil -*-
#
# 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 the Bugzilla Bug Tracking System.
#
# The Initial Developer of the Original Code is Netscape Communications
# Corporation. Portions created by Netscape are
# Copyright (C) 1998 Netscape Communications Corporation. All
# Rights Reserved.
#
# Contributor(s): Myk Melez <myk@mozilla.org>
################################################################################
# Module Initialization
################################################################################
# Make it harder for us to do dangerous things in Perl.
use diagnostics;
use strict;
# Bundle the functions in this file together into the "Token" package.
package Token;
use Date::Format;
# This module requires that its caller have said "require CGI.pl" to import
# relevant functions from that script and its companion globals.pl.
################################################################################
# Constants
################################################################################
# The maximum number of days a token will remain valid.
my $maxtokenage = 3;
################################################################################
# Functions
################################################################################
sub IssueEmailChangeToken {
my ($userid, $old_email, $new_email) = @_;
my $token_ts = time();
my $issuedate = time2str("%Y-%m-%d %H:%M", $token_ts);
# Generate a unique token and insert it into the tokens table.
# We have to lock the tokens table before generating the token,
# since the database must be queried for token uniqueness.
&::SendSQL("LOCK TABLES tokens WRITE");
my $token = GenerateUniqueToken();
my $quotedtoken = &::SqlQuote($token);
my $quoted_emails = &::SqlQuote($old_email . ":" . $new_email);
&::SendSQL("INSERT INTO tokens ( userid , issuedate , token ,
tokentype , eventdata )
VALUES ( $userid , '$issuedate' , $quotedtoken ,
'emailold' , $quoted_emails )");
my $newtoken = GenerateUniqueToken();
$quotedtoken = &::SqlQuote($newtoken);
&::SendSQL("INSERT INTO tokens ( userid , issuedate , token ,
tokentype , eventdata )
VALUES ( $userid , '$issuedate' , $quotedtoken ,
'emailnew' , $quoted_emails )");
&::SendSQL("UNLOCK TABLES");
# Mail the user the token along with instructions for using it.
my $template = $::template;
my $vars = $::vars;
$vars->{'oldemailaddress'} = $old_email . &::Param('emailsuffix');
$vars->{'newemailaddress'} = $new_email . &::Param('emailsuffix');
$vars->{'max_token_age'} = $maxtokenage;
$vars->{'token_ts'} = $token_ts;
$vars->{'token'} = $token;
$vars->{'emailaddress'} = $old_email . &::Param('emailsuffix');
my $message;
$template->process("account/email/change-old.txt.tmpl", $vars, \$message)
|| &::ThrowTemplateError($template->error());
open SENDMAIL, "|/usr/lib/sendmail -t -i";
print SENDMAIL $message;
close SENDMAIL;
$vars->{'token'} = $newtoken;
$vars->{'emailaddress'} = $new_email . &::Param('emailsuffix');
$message = "";
$template->process("account/email/change-new.txt.tmpl", $vars, \$message)
|| &::ThrowTemplateError($template->error());
open SENDMAIL, "|/usr/lib/sendmail -t -i";
print SENDMAIL $message;
close SENDMAIL;
}
sub IssuePasswordToken {
# Generates a random token, adds it to the tokens table, and sends it
# to the user with instructions for using it to change their password.
my ($loginname) = @_;
# Retrieve the user's ID from the database.
my $quotedloginname = &::SqlQuote($loginname);
&::SendSQL("SELECT userid FROM profiles WHERE login_name = $quotedloginname");
my ($userid) = &::FetchSQLData();
my $token_ts = time();
my $issuedate = time2str("%Y-%m-%d %H:%M", $token_ts);
# Generate a unique token and insert it into the tokens table.
# We have to lock the tokens table before generating the token,
# since the database must be queried for token uniqueness.
&::SendSQL("LOCK TABLE tokens WRITE") if $::driver eq 'mysql';
my $token = GenerateUniqueToken();
my $quotedtoken = &::SqlQuote($token);
my $quotedipaddr = &::SqlQuote($::ENV{'REMOTE_ADDR'});
&::SendSQL("INSERT INTO tokens ( userid , issuedate , token , tokentype , eventdata )
VALUES ( $userid , '$issuedate' , $quotedtoken , 'password' , $quotedipaddr )");
&::SendSQL("UNLOCK TABLES") if $::driver eq 'mysql';
# Mail the user the token along with instructions for using it.
my $template = $::template;
my $vars = $::vars;
$vars->{'token'} = $token;
$vars->{'emailaddress'} = $loginname . &::Param('emailsuffix');
$vars->{'max_token_age'} = $maxtokenage;
$vars->{'token_ts'} = $token_ts;
my $message = "";
$template->process("account/password/forgotten-password.txt.tmpl",
$vars, \$message)
|| &::ThrowTemplateError($template->error());
open SENDMAIL, "|/usr/lib/sendmail -t -i";
print SENDMAIL $message;
close SENDMAIL;
}
sub CleanTokenTable {
&::SendSQL("LOCK TABLES tokens WRITE") if $::driver eq 'mysql';
if ($::driver eq 'mysql') {
&::SendSQL("DELETE FROM tokens WHERE TO_DAYS(NOW()) - TO_DAYS(issuedate) >= " . $maxtokenage);
} elsif ($::driver eq 'Pg') {
&::SendSQL("DELETE FROM tokens WHERE now() - issuedate >= '$maxtokenage days'");
}
&::SendSQL("UNLOCK TABLES") if $::driver eq 'mysql';
}
sub GenerateUniqueToken {
# Generates a unique random token. Uses &GenerateRandomPassword
# for the tokens themselves and checks uniqueness by searching for
# the token in the "tokens" table. Gives up if it can't come up
# with a token after about one hundred tries.
my $token;
my $duplicate = 1;
my $tries = 0;
while ($duplicate) {
++$tries;
if ($tries > 100) {
&::DisplayError("Something is seriously wrong with the token generation system.");
exit;
}
$token = &::GenerateRandomPassword();
&::SendSQL("SELECT userid FROM tokens WHERE token = " . &::SqlQuote($token));
$duplicate = &::FetchSQLData();
}
return $token;
}
sub Cancel {
# Cancels a previously issued token and notifies the system administrator.
# This should only happen when the user accidentally makes a token request
# or when a malicious hacker makes a token request on behalf of a user.
my ($token, $cancelaction) = @_;
# Quote the token for inclusion in SQL statements.
my $quotedtoken = &::SqlQuote($token);
# Get information about the token being cancelled.
&::SendSQL("SELECT issuedate , tokentype , eventdata , login_name , realname
FROM tokens, profiles
WHERE tokens.userid = profiles.userid
AND token = $quotedtoken");
my ($issuedate, $tokentype, $eventdata, $loginname, $realname) = &::FetchSQLData();
# Get the email address of the Bugzilla maintainer.
my $maintainer = &::Param('maintainer');
# Format the user's real name and email address into a single string.
my $username = $realname ? $realname . " <" . $loginname . ">" : $loginname;
my $template = $::template;
my $vars = $::vars;
$vars->{'emailaddress'} = $username;
$vars->{'maintainer'} = $maintainer;
$vars->{'remoteaddress'} = $::ENV{'REMOTE_ADDR'};
$vars->{'token'} = $token;
$vars->{'tokentype'} = $tokentype;
$vars->{'issuedate'} = $issuedate;
$vars->{'eventdata'} = $eventdata;
$vars->{'cancelaction'} = $cancelaction;
# Notify the user via email about the cancellation.
my $message;
$template->process("account/cancel-token.txt.tmpl", $vars, \$message)
|| &::ThrowTemplateError($template->error());
open SENDMAIL, "|/usr/lib/sendmail -t -i";
print SENDMAIL $message;
close SENDMAIL;
# Delete the token from the database.
&::SendSQL("LOCK TABLE tokens WRITE") if $::driver eq 'mysql';
&::SendSQL("DELETE FROM tokens WHERE token = $quotedtoken");
&::SendSQL("UNLOCK TABLES") if $::driver eq 'mysql';
}
sub HasPasswordToken {
# Returns a password token if the user has one.
my ($userid) = @_;
&::SendSQL("SELECT token FROM tokens
WHERE userid = $userid AND tokentype = 'password' LIMIT 1");
my ($token) = &::FetchSQLData();
return $token;
}
sub HasEmailChangeToken {
# Returns an email change token if the user has one.
my ($userid) = @_;
&::SendSQL("SELECT token FROM tokens
WHERE userid = $userid
AND tokentype = 'emailnew'
OR tokentype = 'emailold' LIMIT 1");
my ($token) = &::FetchSQLData();
return $token;
}
1;

View File

@@ -1,3 +0,0 @@
Please consult The Bugzilla Guide for instructions on how to upgrade
Bugzilla from an older version. The Guide can be found with this
distribution, in docs/html, docs/txt, and docs/sgml.

View File

@@ -1,407 +0,0 @@
This file contains only important changes made to Bugzilla before release
2.8. If you are upgrading from version older than 2.8, please read this file.
If you are upgrading from 2.8 or newer, please read the Installation and
Upgrade instructions in The Bugzilla Guide, found with this distribution in
docs/html, docs/txt, and docs/sgml.
For a complete list of what changes, use Bonsai
(http://cvs-mirror.mozilla.org/webtools/bonsai/cvsqueryform.cgi) to
query the CVS tree. For example,
http://cvs-mirror.mozilla.org/webtools/bonsai/cvsquery.cgi?module=all&branch=HEAD&branchtype=match&dir=mozilla%2Fwebtools%2Fbugzilla&file=&filetype=match&who=&whotype=match&sortby=Date&hours=2&date=week&mindate=&maxdate=&cvsroot=%2Fcvsroot
will tell you what has been changed in the last week.
10/12/99 The CHANGES file is now obsolete! There is a new file called
checksetup.pl. You should get in the habit of running that file every time
you update your installation of Bugzilla. That file will be constantly
updated to automatically update your installation to match any code changes.
If you're curious as to what is going on, changes are commented in that file,
at the end.
Many thanks to Holger Schurig <holgerschurig@nikocity.de> for writing this
script!
10/11/99 Restructured voting database to add a cached value in each
bug recording how many total votes that bug has. While I'm at it, I
removed the unused "area" field from the bugs database. It is
distressing to realize that the bugs table has reached the maximum
number of indices allowed by MySQL (16), which may make future
enhancements awkward.
You must feed the following to MySQL:
alter table bugs drop column area;
alter table bugs add column votes mediumint not null, add index (votes);
You then *must* delete the data/versioncache file when you make this
change, as it contains references to the "area" field. Deleting it is safe,
bugzilla will correctly regenerate it.
If you have been using the voting feature at all, then you will then
need to update the voting cache. You can do this by visiting the
sanitycheck.cgi page, and taking it up on its offer to rebuild the
votes stuff.
10/7/99 Added voting ability. You must run the new script
"makevotestable.sh". You must also feed the following to mysql:
alter table products add column votesperuser smallint not null;
9/15/99 Apparently, newer alphas of MySQL won't allow you to have
"when" as a column name. So, I have had to rename a column in the
bugs_activity table. You must feed the below to mysql or you won't
work at all.
alter table bugs_activity change column when bug_when datetime not null;
8/16/99 Added "OpenVMS" to the list of OS's. Feed this to mysql:
alter table bugs change column op_sys op_sys enum("All", "Windows 3.1", "Windows 95", "Windows 98", "Windows NT", "Mac System 7", "Mac System 7.5", "Mac System 7.6.1", "Mac System 8.0", "Mac System 8.5", "Mac System 8.6", "AIX", "BSDI", "HP-UX", "IRIX", "Linux", "FreeBSD", "OSF/1", "Solaris", "SunOS", "Neutrino", "OS/2", "BeOS", "OpenVMS", "other") not null;
6/22/99 Added an entry to the attachments table to record who the submitter
was. Nothing uses this yet, but it still should be recorded.
alter table attachments add column submitter_id mediumint not null;
You should also run this script to populate the new field:
#!/usr/bonsaitools/bin/perl -w
use diagnostics;
use strict;
require "globals.pl";
$|=1;
ConnectToDatabase();
SendSQL("select bug_id, attach_id from attachments order by bug_id");
my @list;
while (MoreSQLData()) {
my @row = FetchSQLData();
push(@list, \@row);
}
foreach my $ref (@list) {
my ($bug, $attach) = (@$ref);
SendSQL("select long_desc from bugs where bug_id = $bug");
my $comment = FetchOneColumn() . "Created an attachment (id=$attach)";
if ($comment =~ m@-* Additional Comments From ([^ ]*)[- 0-9/:]*\nCreated an attachment \(id=$attach\)@) {
print "Found $1\n";
SendSQL("select userid from profiles where login_name=" .
SqlQuote($1));
my $userid = FetchOneColumn();
if (defined $userid && $userid > 0) {
SendSQL("update attachments set submitter_id=$userid where attach_id = $attach");
}
} else {
print "Bug $bug can't find comment for attachment $attach\n";
}
}
6/14/99 Added "BeOS" to the list of OS's. Feed this to mysql:
alter table bugs change column op_sys op_sys enum("All", "Windows 3.1", "Windows 95", "Windows 98", "Windows NT", "Mac System 7", "Mac System 7.5", "Mac System 7.6.1", "Mac System 8.0", "Mac System 8.5", "Mac System 8.6", "AIX", "BSDI", "HP-UX", "IRIX", "Linux", "FreeBSD", "OSF/1", "Solaris", "SunOS", "Neutrino", "OS/2", "BeOS", "other") not null;
5/27/99 Added support for dependency information. You must run the new
"makedependenciestable.sh" script. You can turn off dependencies with the new
"usedependencies" param, but it defaults to being on. Also, read very
carefully the description for the new "webdotbase" param; you will almost
certainly need to tweak it.
5/24/99 Added "Mac System 8.6" and "Neutrino" to the list of OS's.
Feed this to mysql:
alter table bugs change column op_sys op_sys enum("All", "Windows 3.1", "Windows 95", "Windows 98", "Windows NT", "Mac System 7", "Mac System 7.5", "Mac System 7.6.1", "Mac System 8.0", "Mac System 8.5", "Mac System 8.6", "AIX", "BSDI", "HP-UX", "IRIX", "Linux", "FreeBSD", "OSF/1", "Solaris", "SunOS", "Neutrino", "OS/2", "other") not null;
5/12/99 Added a pref to control how much email you get. This needs a new
column in the profiles table, so feed the following to mysql:
alter table profiles add column emailnotification enum("ExcludeSelfChanges", "CConly", "All") not null default "ExcludeSelfChanges";
5/5/99 Added the ability to search by creation date. To make this perform
well, you ought to do the following:
alter table bugs change column creation_ts creation_ts datetime not null, add index (creation_ts);
4/30/99 Added a new severity, "blocker". To get this into your running
Bugzilla, do the following:
alter table bugs change column bug_severity bug_severity enum("blocker", "critical", "major", "normal", "minor", "trivial", "enhancement") not null;
4/22/99 There was a bug where the long descriptions of bugs had a variety of
newline characters at the end, depending on the operating system of the browser
that submitted the text. This bug has been fixed, so that no further changes
like that will happen. But to fix problems that have already crept into your
database, you can run the following perl script (which is slow and ugly, but
does work:)
#!/usr/bonsaitools/bin/perl -w
use diagnostics;
use strict;
require "globals.pl";
$|=1;
ConnectToDatabase();
SendSQL("select bug_id from bugs order by bug_id");
my @list;
while (MoreSQLData()) {
push(@list, FetchOneColumn());
}
foreach my $id (@list) {
if ($id % 50 == 0) {
print "\n$id ";
}
SendSQL("select long_desc from bugs where bug_id = $id");
my $comment = FetchOneColumn();
my $orig = $comment;
$comment =~ s/\r\n/\n/g; # Get rid of windows-style line endings.
$comment =~ s/\r/\n/g; # Get rid of mac-style line endings.
if ($comment ne $orig) {
SendSQL("update bugs set long_desc = " . SqlQuote($comment) .
" where bug_id = $id");
print ".";
} else {
print "-";
}
}
4/8/99 Added ability to store patches with bugs. This requires a new table
to store the data, so you will need to run the "makeattachmenttable.sh" script.
3/25/99 Unfortunately, the HTML::FromText CPAN module had too many bugs, and
so I had to roll my own. We no longer use the HTML::FromText CPAN module.
3/24/99 (This entry has been removed. It used to say that we required the
HTML::FromText CPAN module, but that's no longer true.)
3/22/99 Added the ability to query by fields which have changed within a date
range. To make this perform a bit better, we need a new index:
alter table bugs_activity add index (field);
3/10/99 Added 'groups' stuff, where we have different group bits that we can
put on a person or on a bug. Some of the group bits control access to bugzilla
features. And a person can't access a bug unless he has every group bit set
that is also set on the bug. See the comments in makegroupstable.sh for a bit
more info.
The 'maintainer' param is now used only as an email address for people to send
complaints to. The groups table is what is now used to determine permissions.
You will need to run the new script "makegroupstable.sh". And then you need to
feed the following lines to MySQL (replace XXX with the login name of the
maintainer, the person you wish to be all-powerful).
alter table bugs add column groupset bigint not null;
alter table profiles add column groupset bigint not null;
update profiles set groupset=0x7fffffffffffffff where login_name = XXX;
3/8/99 Added params to control how priorities are set in a new bug. You can
now choose whether to let submitters of new bugs choose a priority, or whether
they should just accept the default priority (which is now no longer hardcoded
to "P2", but is instead a param.) The default value of the params will cause
the same behavior as before.
3/3/99 Added a "disallownew" field to the products table. If non-zero, then
don't let people file new bugs against this product. (This is for when a
product is retired, but you want to keep the bug reports around for posterity.)
Feed this to MySQL:
alter table products add column disallownew tinyint not null;
2/8/99 Added FreeBSD to the list of OS's. Feed this to MySQL:
alter table bugs change column op_sys op_sys enum("All", "Windows 3.1", "Windows 95", "Windows 98", "Windows NT", "Mac System 7", "Mac System 7.5", "Mac System 7.6.1", "Mac System 8.0", "Mac System 8.5", "AIX", "BSDI", "HP-UX", "IRIX", "Linux", "FreeBSD", "OSF/1", "Solaris", "SunOS", "OS/2", "other") not null;
2/4/99 Added a new column "description" to the components table, and added
links to a new page which will use this to describe the components of a
given product. Feed this to MySQL:
alter table components add column description mediumtext not null;
2/3/99 Added a new column "initialqacontact" to the components table that gives
an initial QA contact field. It may be empty if you wish the initial qa
contact to be empty. If you're not using the QA contact field, you don't need
to add this column, but you might as well be safe and add it anyway:
alter table components add column initialqacontact tinytext not null;
2/2/99 Added a new column "milestoneurl" to the products table that gives a URL
which is to describe the currently defined milestones for a product. If you
don't use target milestone, you might be able to get away without adding this
column, but you might as well be safe and add it anyway:
alter table products add column milestoneurl tinytext not null;
1/29/99 Whoops; had a misspelled op_sys. It was "Mac System 7.1.6"; it should
be "Mac System 7.6.1". It turns out I had no bugs with this value set, so I
could just do the below simple command. If you have bugs with this value, you
may need to do something more complicated.
alter table bugs change column op_sys op_sys enum("All", "Windows 3.1", "Windows 95", "Windows 98", "Windows NT", "Mac System 7", "Mac System 7.5", "Mac System 7.6.1", "Mac System 8.0", "Mac System 8.5", "AIX", "BSDI", "HP-UX", "IRIX", "Linux", "OSF/1", "Solaris", "SunOS", "OS/2", "other") not null;
1/20/99 Added new fields: Target Milestone, QA Contact, and Status Whiteboard.
These fields are all optional in the UI; there are parameters to turn them on.
However, whether or not you use them, the fields need to be in the DB. There
is some code that needs them, even if you don't.
To update your DB to have these fields, send the following to MySQL:
alter table bugs add column target_milestone varchar(20) not null,
add column qa_contact mediumint not null,
add column status_whiteboard mediumtext not null,
add index (target_milestone), add index (qa_contact);
1/18/99 You can now query by CC. To make this perform reasonably, the CC table
needs some indices. The following MySQL does the necessary stuff:
alter table cc add index (bug_id), add index (who);
1/15/99 The op_sys field can now be queried by (and more easily tweaked).
To make this perform reasonably, it needs an index. The following MySQL
command will create the necessary index:
alter table bugs add index (op_sys);
12/2/98 The op_sys and rep_platform fields have been tweaked. op_sys
is now an enum, rather than having the legal values all hard-coded in
perl. rep_platform now no longer allows a value of "X-Windows".
Here's how I ported to the new world. This ought to work for you too.
Actually, it's probably overkill. I had a lot of illegal values for op_sys
in my tables, from importing bugs from strange places. If you haven't done
anything funky, then much of the below will be a no-op.
First, send the following commands to MySQL to make sure all your values for
rep_platform and op_sys are legal in the new world..
update bugs set rep_platform="Sun" where rep_platform="X-Windows" and op_sys like "Solaris%";
update bugs set rep_platform="SGI" where rep_platform="X-Windows" and op_sys = "IRIX";
update bugs set rep_platform="SGI" where rep_platform="X-Windows" and op_sys = "HP-UX";
update bugs set rep_platform="DEC" where rep_platform="X-Windows" and op_sys = "OSF/1";
update bugs set rep_platform="PC" where rep_platform="X-Windows" and op_sys = "Linux";
update bugs set rep_platform="other" where rep_platform="X-Windows";
update bugs set rep_platform="other" where rep_platform="";
update bugs set op_sys="Mac System 7" where op_sys="System 7";
update bugs set op_sys="Mac System 7.5" where op_sys="System 7.5";
update bugs set op_sys="Mac System 8.0" where op_sys="8.0";
update bugs set op_sys="OSF/1" where op_sys="Digital Unix 4.0";
update bugs set op_sys="IRIX" where op_sys like "IRIX %";
update bugs set op_sys="HP-UX" where op_sys like "HP-UX %";
update bugs set op_sys="Windows NT" where op_sys like "NT %";
update bugs set op_sys="OSF/1" where op_sys like "OSF/1 %";
update bugs set op_sys="Solaris" where op_sys like "Solaris %";
update bugs set op_sys="SunOS" where op_sys like "SunOS%";
update bugs set op_sys="other" where op_sys = "Motif";
update bugs set op_sys="other" where op_sys = "Other";
Next, send the following commands to make sure you now have only legal
entries in your table. If either of the queries do not come up empty, then
you have to do more stuff like the above.
select bug_id,op_sys,rep_platform from bugs where rep_platform not regexp "^(All|DEC|HP|Macintosh|PC|SGI|Sun|X-Windows|Other)$";
select bug_id,op_sys,rep_platform from bugs where op_sys not regexp "^(All|Windows 3.1|Windows 95|Windows 98|Windows NT|Mac System 7|Mac System 7.5|Mac System 7.1.6|Mac System 8.0|AIX|BSDI|HP-UX|IRIX|Linux|OSF/1|Solaris|SunOS|other)$";
Finally, once that's all clear, alter the table to make enforce the new legal
entries:
alter table bugs change column op_sys op_sys enum("All", "Windows 3.1", "Windows 95", "Windows 98", "Windows NT", "Mac System 7", "Mac System 7.5", "Mac System 7.1.6", "Mac System 8.0", "AIX", "BSDI", "HP-UX", "IRIX", "Linux", "OSF/1", "Solaris", "SunOS", "other") not null, change column rep_platform rep_platform enum("All", "DEC", "HP", "Macintosh", "PC", "SGI", "Sun", "Other");
11/20/98 Added searching of CC field. To better support this, added
some indexes to the CC table. You probably want to execute the following
mysql commands:
alter table cc add index (bug_id);
alter table cc add index (who);
10/27/98 security check for legal products in place. bug charts are not
available as an option if collectstats.pl has never been run. all products
get daily stats collected now. README updated: Chart::Base is listed as
a requirement, instructions for using collectstats.pl included as
an optional step. also got silly and added optional quips to bug
reports.
10/17/98 modified README installation instructions slightly.
10/7/98 Added a new table called "products". Right now, this is used
only to have a description for each product, and that description is
only used when initially adding a new bug. Anyway, you *must* create
the new table (which you can do by running the new makeproducttable.sh
script). If you just leave it empty, things will work much as they
did before, or you can add descriptions for some or all of your
products.
9/15/98 Everything has been ported to Perl. NO MORE TCL. This
transition should be relatively painless, except for the "params"
file. This is the file that contains parameters you've set up on the
editparams.cgi page. Before changing to Perl, this was a tcl-syntax
file, stored in the same directory as the code; after the change to
Perl, it becomes a perl-syntax file, stored in a subdirectory named
"data". See the README file for more details on what version of Perl
you need.
So, if updating from an older version of Bugzilla, you will need to
edit data/param, change the email address listed for
$::param{'maintainer'}, and then go revisit the editparams.cgi page
and reset all the parameters to your taste. Fortunately, your old
params file will still be around, and so you ought to be able to
cut&paste important bits from there.
Also, note that the "whineatnews" script has changed name (it now has
an extension of .pl instead of .tcl), so you'll need to change your
cron job.
And the "comments" file has been moved to the data directory. Just do
"cat comments >> data/comments" to restore any old comments that may
have been lost.
9/2/98 Changed the way password validation works. We now keep a
crypt'd version of the password in the database, and check against
that. (This is silly, because we're also keeping the plaintext
version there, but I have plans...) Stop passing the plaintext
password around as a cookie; instead, we have a cookie that references
a record in a new database table, logincookies.
IMPORTANT: if updating from an older version of Bugzilla, you must run
the following commands to keep things working:
./makelogincookiestable.sh
echo "alter table profiles add column cryptpassword varchar(64);" | mysql bugs
echo "update profiles set cryptpassword = encrypt(password,substring(rand(),3, 4));" | mysql bugs

Binary file not shown.

Before

Width:  |  Height:  |  Size: 8.3 KiB

View File

@@ -1,792 +0,0 @@
#!/usr/bonsaitools/bin/perl -wT
# -*- Mode: perl; indent-tabs-mode: nil -*-
#
# 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 the Bugzilla Bug Tracking System.
#
# The Initial Developer of the Original Code is Netscape Communications
# Corporation. Portions created by Netscape are
# Copyright (C) 1998 Netscape Communications Corporation. All
# Rights Reserved.
#
# Contributor(s): Terry Weissman <terry@mozilla.org>
# Myk Melez <myk@mozilla.org>
################################################################################
# Script Initialization
################################################################################
# Make it harder for us to do dangerous things in Perl.
use diagnostics;
use strict;
use lib qw(.);
use vars qw(
$template
$vars
);
# Include the Bugzilla CGI and general utility library.
require "CGI.pl";
# Establish a connection to the database backend.
ConnectToDatabase();
# Check whether or not the user is logged in and, if so, set the $::userid
# and $::usergroupset variables.
quietly_check_login();
################################################################################
# Main Body Execution
################################################################################
# All calls to this script should contain an "action" variable whose value
# determines what the user wants to do. The code below checks the value of
# that variable and runs the appropriate code.
# Determine whether to use the action specified by the user or the default.
my $action = $::FORM{'action'} || 'view';
if ($action eq "view")
{
validateID();
view();
}
elsif ($action eq "viewall")
{
ValidateBugID($::FORM{'bugid'});
viewall();
}
elsif ($action eq "enter")
{
confirm_login();
ValidateBugID($::FORM{'bugid'});
enter();
}
elsif ($action eq "insert")
{
confirm_login();
ValidateBugID($::FORM{'bugid'});
ValidateComment($::FORM{'comment'});
validateFilename();
validateData();
validateDescription();
validateIsPatch();
validateContentType() unless $::FORM{'ispatch'};
validateObsolete() if $::FORM{'obsolete'};
insert();
}
elsif ($action eq "edit")
{
quietly_check_login();
validateID();
validateCanEdit($::FORM{'id'});
edit();
}
elsif ($action eq "update")
{
confirm_login();
ValidateComment($::FORM{'comment'});
validateID();
validateCanEdit($::FORM{'id'});
validateDescription();
validateIsPatch();
validateContentType() unless $::FORM{'ispatch'};
validateIsObsolete();
validateStatuses();
update();
}
else
{
DisplayError("I could not figure out what you wanted to do.")
}
exit;
################################################################################
# Data Validation / Security Authorization
################################################################################
sub validateID
{
# Validate the value of the "id" form field, which must contain an
# integer that is the ID of an existing attachment.
detaint_natural($::FORM{'id'})
|| DisplayError("You did not enter a valid attachment number.")
&& exit;
# Make sure the attachment exists in the database.
SendSQL("SELECT bug_id FROM attachments WHERE attach_id = $::FORM{'id'}");
MoreSQLData()
|| DisplayError("Attachment #$::FORM{'id'} does not exist.")
&& exit;
# Make sure the user is authorized to access this attachment's bug.
my ($bugid) = FetchSQLData();
ValidateBugID($bugid);
}
sub validateCanEdit
{
my ($attach_id) = (@_);
# If the user is not logged in, claim that they can edit. This allows
# the edit scrren to be displayed to people who aren't logged in.
# People not logged in can't actually commit changes, because that code
# calls confirm_login, not quietly_check_login, before calling this sub
return if $::userid == 0;
# People in editbugs can edit all attachments
return if UserInGroup("editbugs");
# Bug 97729 - the submitter can edit their attachments
SendSQL("SELECT attach_id FROM attachments WHERE " .
"attach_id = $attach_id AND submitter_id = $::userid");
FetchSQLData()
|| DisplayError("You are not authorised to edit attachment #$attach_id")
&& exit;
}
sub validateDescription
{
$::FORM{'description'}
|| DisplayError("You must enter a description for the attachment.")
&& exit;
}
sub validateIsPatch
{
# Set the ispatch flag to zero if it is undefined, since the UI uses
# an HTML checkbox to represent this flag, and unchecked HTML checkboxes
# do not get sent in HTML requests.
$::FORM{'ispatch'} = $::FORM{'ispatch'} ? 1 : 0;
# Set the content type to text/plain if the attachment is a patch.
$::FORM{'contenttype'} = "text/plain" if $::FORM{'ispatch'};
}
sub validateContentType
{
if (!$::FORM{'contenttypemethod'})
{
DisplayError("You must choose a method for determining the content type,
either <em>auto-detect</em>, <em>select from list</em>, or <em>enter
manually</em>.");
exit;
}
elsif ($::FORM{'contenttypemethod'} eq 'autodetect')
{
# The user asked us to auto-detect the content type, so use the type
# specified in the HTTP request headers.
if ( !$::FILE{'data'}->{'contenttype'} )
{
DisplayError("You asked Bugzilla to auto-detect the content type, but
your browser did not specify a content type when uploading the file,
so you must enter a content type manually.");
exit;
}
$::FORM{'contenttype'} = $::FILE{'data'}->{'contenttype'};
}
elsif ($::FORM{'contenttypemethod'} eq 'list')
{
# The user selected a content type from the list, so use their selection.
$::FORM{'contenttype'} = $::FORM{'contenttypeselection'};
}
elsif ($::FORM{'contenttypemethod'} eq 'manual')
{
# The user entered a content type manually, so use their entry.
$::FORM{'contenttype'} = $::FORM{'contenttypeentry'};
}
else
{
my $htmlcontenttypemethod = html_quote($::FORM{'contenttypemethod'});
DisplayError("Your form submission got corrupted somehow. The <em>content
method</em> field, which specifies how the content type gets determined,
should have been either <em>autodetect</em>, <em>list</em>,
or <em>manual</em>, but was instead <em>$htmlcontenttypemethod</em>.");
exit;
}
if ( $::FORM{'contenttype'} !~ /^(application|audio|image|message|model|multipart|text|video)\/.+$/ )
{
my $htmlcontenttype = html_quote($::FORM{'contenttype'});
DisplayError("The content type <em>$htmlcontenttype</em> is invalid.
Valid types must be of the form <em>foo/bar</em> where <em>foo</em>
is either <em>application, audio, image, message, model, multipart,
text,</em> or <em>video</em>.");
exit;
}
}
sub validateIsObsolete
{
# Set the isobsolete flag to zero if it is undefined, since the UI uses
# an HTML checkbox to represent this flag, and unchecked HTML checkboxes
# do not get sent in HTML requests.
$::FORM{'isobsolete'} = $::FORM{'isobsolete'} ? 1 : 0;
}
sub validateStatuses
{
# Get a list of attachment statuses that are valid for this attachment.
PushGlobalSQLState();
SendSQL("SELECT attachstatusdefs.id
FROM attachments, bugs, attachstatusdefs
WHERE attachments.attach_id = $::FORM{'id'}
AND attachments.bug_id = bugs.bug_id
AND attachstatusdefs.product = bugs.product");
my @statusdefs;
push(@statusdefs, FetchSQLData()) while MoreSQLData();
PopGlobalSQLState();
foreach my $status (@{$::MFORM{'status'}})
{
grep($_ == $status, @statusdefs)
|| DisplayError("One of the statuses you entered is not a valid status
for this attachment.")
&& exit;
# We have tested that the status is valid, so it can be detainted
detaint_natural($status);
}
}
sub validateData
{
$::FORM{'data'}
|| DisplayError("The file you are trying to attach is empty!")
&& exit;
my $len = length($::FORM{'data'});
my $maxpatchsize = Param('maxpatchsize');
my $maxattachmentsize = Param('maxattachmentsize');
# Makes sure the attachment does not exceed either the "maxpatchsize" or
# the "maxattachmentsize" parameter.
if ( $::FORM{'ispatch'} && $maxpatchsize && $len > $maxpatchsize*1024 )
{
my $lenkb = sprintf("%.0f", $len/1024);
DisplayError("The file you are trying to attach is ${lenkb} kilobytes (KB) in size.
Patches cannot be more than ${maxpatchsize}KB in size.
Try breaking your patch into several pieces.");
exit;
} elsif ( !$::FORM{'ispatch'} && $maxattachmentsize && $len > $maxattachmentsize*1024 ) {
my $lenkb = sprintf("%.0f", $len/1024);
DisplayError("The file you are trying to attach is ${lenkb} kilobytes (KB) in size.
Non-patch attachments cannot be more than ${maxattachmentsize}KB.
If your attachment is an image, try converting it to a compressable
format like JPG or PNG, or put it elsewhere on the web and
link to it from the bug's URL field or in a comment on the bug.");
exit;
}
}
sub validateFilename
{
defined $::FILE{'data'}
|| DisplayError("You did not specify a file to attach.")
&& exit;
}
sub validateObsolete
{
# Make sure the attachment id is valid and the user has permissions to view
# the bug to which it is attached.
foreach my $attachid (@{$::MFORM{'obsolete'}}) {
detaint_natural($attachid)
|| DisplayError("The attachment number of one of the attachments
you wanted to obsolete is invalid.")
&& exit;
SendSQL("SELECT bug_id, isobsolete, description
FROM attachments WHERE attach_id = $attachid");
# Make sure the attachment exists in the database.
MoreSQLData()
|| DisplayError("Attachment #$attachid does not exist.")
&& exit;
my ($bugid, $isobsolete, $description) = FetchSQLData();
if ($bugid != $::FORM{'bugid'})
{
$description = html_quote($description);
DisplayError("Attachment #$attachid ($description) is attached
to bug #$bugid, but you tried to flag it as obsolete while
creating a new attachment to bug #$::FORM{'bugid'}.");
exit;
}
if ( $isobsolete )
{
$description = html_quote($description);
DisplayError("Attachment #$attachid ($description) is already obsolete.");
exit;
}
# Check that the user can modify this attachment
validateCanEdit($attachid);
}
}
################################################################################
# Functions
################################################################################
sub view
{
# Display an attachment.
# Retrieve the attachment content and its content type from the database.
SendSQL("SELECT mimetype, thedata FROM attachments WHERE attach_id = $::FORM{'id'}");
my ($contenttype, $thedata) = FetchSQLData();
# Return the appropriate HTTP response headers.
print "Content-Type: $contenttype\n\n";
print $thedata;
}
sub viewall
{
# Display all attachments for a given bug in a series of IFRAMEs within one HTML page.
# Retrieve the attachments from the database and write them into an array
# of hashes where each hash represents one attachment.
SendSQL("SELECT attach_id, creation_ts, mimetype, description, ispatch, isobsolete
FROM attachments WHERE bug_id = $::FORM{'bugid'} ORDER BY attach_id");
my @attachments; # the attachments array
while (MoreSQLData())
{
my %a; # the attachment hash
($a{'attachid'}, $a{'date'}, $a{'contenttype'},
$a{'description'}, $a{'ispatch'}, $a{'isobsolete'}) = FetchSQLData();
# Format the attachment's creation/modification date into something readable.
if ($a{'date'} =~ /^(\d\d)(\d\d)(\d\d)(\d\d)(\d\d)(\d\d)(\d\d)$/) {
$a{'date'} = "$3/$4/$2&nbsp;$5:$6";
}
# Flag attachments as to whether or not they can be viewed (as opposed to
# being downloaded). Currently I decide they are viewable if their MIME type
# is either text/*, image/*, or application/vnd.mozilla.*.
# !!! Yuck, what an ugly hack. Fix it!
$a{'isviewable'} = ( $a{'contenttype'} =~ /^(text|image|application\/vnd\.mozilla\.)/ );
# Retrieve a list of status flags that have been set on the attachment.
PushGlobalSQLState();
SendSQL("SELECT name
FROM attachstatuses, attachstatusdefs
WHERE attach_id = $a{'attachid'}
AND attachstatuses.statusid = attachstatusdefs.id
ORDER BY sortkey");
my @statuses;
push(@statuses, FetchSQLData()) while MoreSQLData();
$a{'statuses'} = \@statuses;
PopGlobalSQLState();
# Add the hash representing the attachment to the array of attachments.
push @attachments, \%a;
}
# Retrieve the bug summary for displaying on screen.
SendSQL("SELECT short_desc FROM bugs WHERE bug_id = $::FORM{'bugid'}");
my ($bugsummary) = FetchSQLData();
# Define the variables and functions that will be passed to the UI template.
$vars->{'bugid'} = $::FORM{'bugid'};
$vars->{'bugsummary'} = $bugsummary;
$vars->{'attachments'} = \@attachments;
# Return the appropriate HTTP response headers.
print "Content-Type: text/html\n\n";
# Generate and return the UI (HTML page) from the appropriate template.
$template->process("attachment/show-multiple.html.tmpl", $vars)
|| ThrowTemplateError($template->error());
}
sub enter
{
# Display a form for entering a new attachment.
# Retrieve the attachments the user can edit from the database and write
# them into an array of hashes where each hash represents one attachment.
my $canEdit = "";
if (!UserInGroup("editbugs")) {
$canEdit = "AND submitter_id = $::userid";
}
SendSQL("SELECT attach_id, description
FROM attachments
WHERE bug_id = $::FORM{'bugid'}
AND isobsolete = 0 $canEdit
ORDER BY attach_id");
my @attachments; # the attachments array
while ( MoreSQLData() ) {
my %a; # the attachment hash
($a{'id'}, $a{'description'}) = FetchSQLData();
# Add the hash representing the attachment to the array of attachments.
push @attachments, \%a;
}
# Retrieve the bug summary for displaying on screen.
SendSQL("SELECT short_desc FROM bugs WHERE bug_id = $::FORM{'bugid'}");
my ($bugsummary) = FetchSQLData();
# Define the variables and functions that will be passed to the UI template.
$vars->{'bugid'} = $::FORM{'bugid'};
$vars->{'bugsummary'} = $bugsummary;
$vars->{'attachments'} = \@attachments;
# Return the appropriate HTTP response headers.
print "Content-Type: text/html\n\n";
# Generate and return the UI (HTML page) from the appropriate template.
$template->process("attachment/create.html.tmpl", $vars)
|| ThrowTemplateError($template->error());
}
sub insert
{
# Insert a new attachment into the database.
# Escape characters in strings that will be used in SQL statements.
my $filename = SqlQuote($::FILE{'data'}->{'filename'});
my $description = SqlQuote($::FORM{'description'});
my $contenttype = SqlQuote($::FORM{'contenttype'});
my $thedata = SqlQuote($::FORM{'data'});
# Insert the attachment into the database.
SendSQL("INSERT INTO attachments (bug_id, filename, description, mimetype, ispatch, submitter_id, thedata)
VALUES ($::FORM{'bugid'}, $filename, $description, $contenttype, $::FORM{'ispatch'}, $::userid, $thedata)");
# Retrieve the ID of the newly created attachment record.
SendSQL("SELECT LAST_INSERT_ID()");
my $attachid = FetchOneColumn();
# Insert a comment about the new attachment into the database.
my $comment = "Created an attachment (id=$attachid)\n$::FORM{'description'}\n";
$comment .= ("\n" . $::FORM{'comment'}) if $::FORM{'comment'};
use Text::Wrap;
$Text::Wrap::columns = 80;
$Text::Wrap::huge = 'overflow';
$comment = Text::Wrap::wrap('', '', $comment);
AppendComment($::FORM{'bugid'},
$::COOKIE{"Bugzilla_login"},
$comment);
# Make existing attachments obsolete.
my $fieldid = GetFieldID('attachments.isobsolete');
foreach my $attachid (@{$::MFORM{'obsolete'}}) {
SendSQL("UPDATE attachments SET isobsolete = 1 WHERE attach_id = $attachid");
SendSQL("INSERT INTO bugs_activity (bug_id, attach_id, who, bug_when, fieldid, removed, added)
VALUES ($::FORM{'bugid'}, $attachid, $::userid, NOW(), $fieldid, '0', '1')");
}
# Send mail to let people know the attachment has been created. Uses a
# special syntax of the "open" and "exec" commands to capture the output of
# "processmail", which "system" doesn't allow, without running the command
# through a shell, which backticks (``) do.
#system ("./processmail", $bugid , $::userid);
#my $mailresults = `./processmail $bugid $::userid`;
my $mailresults = '';
open(PMAIL, "-|") or exec('./processmail', $::FORM{'bugid'}, $::COOKIE{'Bugzilla_login'});
$mailresults .= $_ while <PMAIL>;
close(PMAIL);
# Define the variables and functions that will be passed to the UI template.
$vars->{'bugid'} = $::FORM{'bugid'};
$vars->{'attachid'} = $attachid;
$vars->{'description'} = $description;
$vars->{'mailresults'} = $mailresults;
$vars->{'contenttypemethod'} = $::FORM{'contenttypemethod'};
$vars->{'contenttype'} = $::FORM{'contenttype'};
# Return the appropriate HTTP response headers.
print "Content-Type: text/html\n\n";
# Generate and return the UI (HTML page) from the appropriate template.
$template->process("attachment/created.html.tmpl", $vars)
|| ThrowTemplateError($template->error());
}
sub edit
{
# Edit an attachment record. Users with "editbugs" privileges, (or the
# original attachment's submitter) can edit the attachment's description,
# content type, ispatch and isobsolete flags, and statuses, and they can
# also submit a comment that appears in the bug.
# Users cannot edit the content of the attachment itself.
# Retrieve the attachment from the database.
SendSQL("SELECT description, mimetype, bug_id, ispatch, isobsolete
FROM attachments WHERE attach_id = $::FORM{'id'}");
my ($description, $contenttype, $bugid, $ispatch, $isobsolete) = FetchSQLData();
# Flag attachment as to whether or not it can be viewed (as opposed to
# being downloaded). Currently I decide it is viewable if its content
# type is either text/.* or application/vnd.mozilla.*.
# !!! Yuck, what an ugly hack. Fix it!
my $isviewable = ( $contenttype =~ /^(text|image|application\/vnd\.mozilla\.)/ );
# Retrieve a list of status flags that have been set on the attachment.
my %statuses;
SendSQL("SELECT id, name
FROM attachstatuses JOIN attachstatusdefs
WHERE attachstatuses.statusid = attachstatusdefs.id
AND attach_id = $::FORM{'id'}");
while ( my ($id, $name) = FetchSQLData() )
{
$statuses{$id} = $name;
}
# Retrieve a list of statuses for this bug's product, and build an array
# of hashes in which each hash is a status flag record.
# ???: Move this into versioncache or its own routine?
my @statusdefs;
SendSQL("SELECT id, name
FROM attachstatusdefs, bugs
WHERE bug_id = $bugid
AND attachstatusdefs.product = bugs.product
ORDER BY sortkey");
while ( MoreSQLData() )
{
my ($id, $name) = FetchSQLData();
push @statusdefs, { 'id' => $id , 'name' => $name };
}
# Retrieve a list of attachments for this bug as well as a summary of the bug
# to use in a navigation bar across the top of the screen.
SendSQL("SELECT attach_id FROM attachments WHERE bug_id = $bugid ORDER BY attach_id");
my @bugattachments;
push(@bugattachments, FetchSQLData()) while (MoreSQLData());
SendSQL("SELECT short_desc FROM bugs WHERE bug_id = $bugid");
my ($bugsummary) = FetchSQLData();
# Define the variables and functions that will be passed to the UI template.
$vars->{'attachid'} = $::FORM{'id'};
$vars->{'description'} = $description;
$vars->{'contenttype'} = $contenttype;
$vars->{'bugid'} = $bugid;
$vars->{'bugsummary'} = $bugsummary;
$vars->{'ispatch'} = $ispatch;
$vars->{'isobsolete'} = $isobsolete;
$vars->{'isviewable'} = $isviewable;
$vars->{'statuses'} = \%statuses;
$vars->{'statusdefs'} = \@statusdefs;
$vars->{'attachments'} = \@bugattachments;
# Return the appropriate HTTP response headers.
print "Content-Type: text/html\n\n";
# Generate and return the UI (HTML page) from the appropriate template.
$template->process("attachment/edit.html.tmpl", $vars)
|| ThrowTemplateError($template->error());
}
sub update
{
# Update an attachment record.
# Get the bug ID for the bug to which this attachment is attached.
SendSQL("SELECT bug_id FROM attachments WHERE attach_id = $::FORM{'id'}");
my $bugid = FetchSQLData()
|| DisplayError("Cannot figure out bug number.")
&& exit;
# Lock database tables in preparation for updating the attachment.
if ($::driver eq 'mysql') {
SendSQL("LOCK TABLES attachments WRITE , attachstatuses WRITE ,
attachstatusdefs READ , fielddefs READ , bugs_activity WRITE");
}
# Get a copy of the attachment record before we make changes
# so we can record those changes in the activity table.
SendSQL("SELECT description, mimetype, ispatch, isobsolete
FROM attachments WHERE attach_id = $::FORM{'id'}");
my ($olddescription, $oldcontenttype, $oldispatch, $oldisobsolete) = FetchSQLData();
# Get the list of old status flags.
SendSQL("SELECT attachstatusdefs.name
FROM attachments, attachstatuses, attachstatusdefs
WHERE attachments.attach_id = $::FORM{'id'}
AND attachments.attach_id = attachstatuses.attach_id
AND attachstatuses.statusid = attachstatusdefs.id
ORDER BY attachstatusdefs.sortkey
");
my @oldstatuses;
while (MoreSQLData()) {
push(@oldstatuses, FetchSQLData());
}
my $oldstatuslist = join(', ', @oldstatuses);
# Update the database with the new status flags.
SendSQL("DELETE FROM attachstatuses WHERE attach_id = $::FORM{'id'}");
foreach my $statusid (@{$::MFORM{'status'}})
{
SendSQL("INSERT INTO attachstatuses (attach_id, statusid) VALUES ($::FORM{'id'}, $statusid)");
}
# Get the list of new status flags.
SendSQL("SELECT attachstatusdefs.name
FROM attachments, attachstatuses, attachstatusdefs
WHERE attachments.attach_id = $::FORM{'id'}
AND attachments.attach_id = attachstatuses.attach_id
AND attachstatuses.statusid = attachstatusdefs.id
ORDER BY attachstatusdefs.sortkey
");
my @newstatuses;
while (MoreSQLData()) {
push(@newstatuses, FetchSQLData());
}
my $newstatuslist = join(', ', @newstatuses);
# Quote the description and content type for use in the SQL UPDATE statement.
my $quoteddescription = SqlQuote($::FORM{'description'});
my $quotedcontenttype = SqlQuote($::FORM{'contenttype'});
# Update the attachment record in the database.
# Sets the creation timestamp to itself to avoid it being updated automatically.
SendSQL("UPDATE attachments
SET description = $quoteddescription ,
mimetype = $quotedcontenttype ,
ispatch = $::FORM{'ispatch'} ,
isobsolete = $::FORM{'isobsolete'} ,
creation_ts = creation_ts
WHERE attach_id = $::FORM{'id'}
");
# Record changes in the activity table.
if ($olddescription ne $::FORM{'description'}) {
my $quotedolddescription = SqlQuote($olddescription);
my $fieldid = GetFieldID('attachments.description');
SendSQL("INSERT INTO bugs_activity (bug_id, attach_id, who, bug_when, fieldid, removed, added)
VALUES ($bugid, $::FORM{'id'}, $::userid, NOW(), $fieldid, $quotedolddescription, $quoteddescription)");
}
if ($oldcontenttype ne $::FORM{'contenttype'}) {
my $quotedoldcontenttype = SqlQuote($oldcontenttype);
my $fieldid = GetFieldID('attachments.mimetype');
SendSQL("INSERT INTO bugs_activity (bug_id, attach_id, who, bug_when, fieldid, removed, added)
VALUES ($bugid, $::FORM{'id'}, $::userid, NOW(), $fieldid, $quotedoldcontenttype, $quotedcontenttype)");
}
if ($oldispatch ne $::FORM{'ispatch'}) {
my $fieldid = GetFieldID('attachments.ispatch');
SendSQL("INSERT INTO bugs_activity (bug_id, attach_id, who, bug_when, fieldid, removed, added)
VALUES ($bugid, $::FORM{'id'}, $::userid, NOW(), $fieldid, $oldispatch, $::FORM{'ispatch'})");
}
if ($oldisobsolete ne $::FORM{'isobsolete'}) {
my $fieldid = GetFieldID('attachments.isobsolete');
SendSQL("INSERT INTO bugs_activity (bug_id, attach_id, who, bug_when, fieldid, removed, added)
VALUES ($bugid, $::FORM{'id'}, $::userid, NOW(), $fieldid, $oldisobsolete, $::FORM{'isobsolete'})");
}
if ($oldstatuslist ne $newstatuslist) {
my ($removed, $added) = DiffStrings($oldstatuslist, $newstatuslist);
my $quotedremoved = SqlQuote($removed);
my $quotedadded = SqlQuote($added);
my $fieldid = GetFieldID('attachstatusdefs.name');
SendSQL("INSERT INTO bugs_activity (bug_id, attach_id, who, bug_when, fieldid, removed, added)
VALUES ($bugid, $::FORM{'id'}, $::userid, NOW(), $fieldid, $quotedremoved, $quotedadded)");
}
# Unlock all database tables now that we are finished updating the database.
if ($::driver eq 'mysql') {
SendSQL("UNLOCK TABLES");
}
# If this installation has enabled the request manager, let the manager know
# an attachment was updated so it can check for requests on that attachment
# and fulfill them. The request manager allows users to request database
# changes of other users and tracks the fulfillment of those requests. When
# an attachment record is updated and the request manager is called, it will
# fulfill those requests that were requested of the user performing the update
# which are requests for the attachment being updated.
#my $requests;
#if (Param('userequestmanager'))
#{
# use Request;
# # Specify the fieldnames that have been updated.
# my @fieldnames = ('description', 'mimetype', 'status', 'ispatch', 'isobsolete');
# # Fulfill pending requests.
# $requests = Request::fulfillRequest('attachment', $::FORM{'id'}, @fieldnames);
# $vars->{'requests'} = $requests;
#}
# If the user submitted a comment while editing the attachment,
# add the comment to the bug.
if ( $::FORM{'comment'} )
{
use Text::Wrap;
$Text::Wrap::columns = 80;
$Text::Wrap::huge = 'wrap';
# Append a string to the comment to let users know that the comment came from
# the "edit attachment" screen.
my $comment = qq|(From update of attachment $::FORM{'id'})\n| . $::FORM{'comment'};
my $wrappedcomment = "";
foreach my $line (split(/\r\n|\r|\n/, $comment))
{
if ( $line =~ /^>/ )
{
$wrappedcomment .= $line . "\n";
}
else
{
$wrappedcomment .= wrap('', '', $line) . "\n";
}
}
# Get the user's login name since the AppendComment function needs it.
my $who = DBID_to_name($::userid);
# Mention $::userid again so Perl doesn't give me a warning about it.
my $neverused = $::userid;
# Append the comment to the list of comments in the database.
AppendComment($bugid, $who, $wrappedcomment);
}
# Send mail to let people know the bug has changed. Uses a special syntax
# of the "open" and "exec" commands to capture the output of "processmail",
# which "system" doesn't allow, without running the command through a shell,
# which backticks (``) do.
#system ("./processmail", $bugid , $::userid);
#my $mailresults = `./processmail $bugid $::userid`;
my $mailresults = '';
open(PMAIL, "-|") or exec('./processmail', $bugid, DBID_to_name($::userid));
$mailresults .= $_ while <PMAIL>;
close(PMAIL);
# Define the variables and functions that will be passed to the UI template.
$vars->{'attachid'} = $::FORM{'id'};
$vars->{'bugid'} = $bugid;
$vars->{'mailresults'} = $mailresults;
# Return the appropriate HTTP response headers.
print "Content-Type: text/html\n\n";
# Generate and return the UI (HTML page) from the appropriate template.
$template->process("attachment/updated.html.tmpl", $vars)
|| ThrowTemplateError($template->error());
}

View File

@@ -1,378 +0,0 @@
# -*- Mode: perl; indent-tabs-mode: nil -*-
#
# 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 the Bugzilla Bug Tracking System.
#
# The Initial Developer of the Original Code is Netscape Communications
# Corporation. Portions created by Netscape are
# Copyright (C) 1998 Netscape Communications Corporation. All
# Rights Reserved.
#
# Contributor(s): Terry Weissman <terry@mozilla.org>
# Dave Miller <justdave@syndicomm.com>
use diagnostics;
use strict;
use RelationSet;
# Use the Attachment module to display attachments for the bug.
use Attachment;
sub show_bug {
# Shut up misguided -w warnings about "used only once". For some reason,
# "use vars" chokes on me when I try it here.
sub bug_form_pl_sillyness {
my $zz;
$zz = %::FORM;
$zz = %::proddesc;
$zz = %::prodmaxvotes;
$zz = @::enterable_products;
$zz = @::settable_resolution;
$zz = $::unconfirmedstate;
$zz = $::milestoneurl;
$zz = $::template;
$zz = $::vars;
$zz = @::legal_priority;
$zz = @::legal_platform;
$zz = @::legal_severity;
$zz = @::legal_bug_status;
$zz = @::target_milestone;
$zz = @::components;
$zz = @::legal_keywords;
$zz = @::versions;
$zz = @::legal_opsys;
}
# Use templates
my $template = $::template;
my $vars = $::vars;
$vars->{'GetBugLink'} = \&GetBugLink;
$vars->{'quoteUrls'} = \&quoteUrls,
$vars->{'lsearch'} = \&lsearch,
$vars->{'header_done'} = (@_),
quietly_check_login();
my $id = $::FORM{'id'};
if (!defined($id)) {
$template->process("bug/choose.html.tmpl", $vars)
|| ThrowTemplateError($template->error());
exit;
}
my %user = %{$vars->{'user'}};
my %bug;
# Populate the bug hash with the info we get directly from the DB.
my $query = "
SELECT
bugs.bug_id,
product,
version,
rep_platform,
op_sys,
bug_status,
resolution,
priority,
bug_severity,
component,
assigned_to,
reporter,
bug_file_loc,
short_desc,
target_milestone,
qa_contact,
status_whiteboard, ";
if ($::driver eq 'mysql') {
$query .= "
date_format(creation_ts, '%Y-%m-%d %H:%i'),
groupset,
delta_ts, ";
} elsif ($::driver eq 'Pg') {
$query .= "
TO_CHAR(creation_ts, 'YYYY-MM-DD HH24:MI:SS'),
groupset,
TO_CHAR(delta_ts, 'YYYYMMDDHH24MISS'), ";
}
$query .= "
SUM(votes.count)
FROM
bugs LEFT JOIN votes USING(bug_id)
WHERE
bugs.bug_id = $id
GROUP BY
bugs.bug_id,
product,
version,
rep_platform,
op_sys,
bug_status,
resolution,
priority,
bug_severity,
component,
assigned_to,
reporter,
bug_file_loc,
short_desc,
target_milestone,
qa_contact,
status_whiteboard,
creation_ts,
groupset,
delta_ts ";
SendSQL($query);
my $value;
my @row = FetchSQLData();
foreach my $field ("bug_id", "product", "version", "rep_platform",
"op_sys", "bug_status", "resolution", "priority",
"bug_severity", "component", "assigned_to", "reporter",
"bug_file_loc", "short_desc", "target_milestone",
"qa_contact", "status_whiteboard", "creation_ts",
"groupset", "delta_ts", "votes")
{
$value = shift(@row);
$bug{$field} = defined($value) ? $value : "";
}
# General arrays of info about the database state
GetVersionTable();
# Fiddle the product list.
my $seen_curr_prod;
my @prodlist;
foreach my $product (@::enterable_products) {
if ($product eq $bug{'product'}) {
# if it's the product the bug is already in, it's ALWAYS in
# the popup, period, whether the user can see it or not, and
# regardless of the disallownew setting.
$seen_curr_prod = 1;
push(@prodlist, $product);
next;
}
if (Param("usebuggroupsentry")
&& GroupExists($product)
&& !UserInGroup($product))
{
# If we're using bug groups to restrict entry on products, and
# this product has a bug group, and the user is not in that
# group, we don't want to include that product in this list.
next;
}
push(@prodlist, $product);
}
# The current product is part of the popup, even if new bugs are no longer
# allowed for that product
if (!$seen_curr_prod) {
push (@prodlist, $bug{'product'});
@prodlist = sort @prodlist;
}
$vars->{'product'} = \@prodlist;
$vars->{'rep_platform'} = \@::legal_platform;
$vars->{'priority'} = \@::legal_priority;
$vars->{'bug_severity'} = \@::legal_severity;
$vars->{'op_sys'} = \@::legal_opsys;
$vars->{'bug_status'} = \@::legal_bug_status;
# Hack - this array contains "" for some reason. See bug 106589.
shift @::settable_resolution;
$vars->{'resolution'} = \@::settable_resolution;
$vars->{'component_'} = $::components{$bug{'product'}};
$vars->{'version'} = $::versions{$bug{'product'}};
$vars->{'target_milestone'} = $::target_milestone{$bug{'product'}};
$bug{'milestoneurl'} = $::milestoneurl{$bug{'product'}} ||
"notargetmilestone.html";
$vars->{'use_votes'} = $::prodmaxvotes{$bug{'product'}};
# Add additional, calculated fields to the bug hash
if (@::legal_keywords) {
$vars->{'use_keywords'} = 1;
SendSQL("SELECT keyworddefs.name
FROM keyworddefs, keywords
WHERE keywords.bug_id = $id
AND keyworddefs.id = keywords.keywordid
ORDER BY keyworddefs.name");
my @keywords;
while (MoreSQLData()) {
push(@keywords, FetchOneColumn());
}
$bug{'keywords'} = \@keywords;
}
# Attachments
$bug{'attachments'} = Attachment::query($id);
# Dependencies
my @list;
SendSQL("SELECT dependson FROM dependencies WHERE
blocked = $id ORDER BY dependson");
while (MoreSQLData()) {
my ($i) = FetchSQLData();
push(@list, $i);
}
$bug{'dependson'} = \@list;
my @list2;
SendSQL("SELECT blocked FROM dependencies WHERE
dependson = $id ORDER BY blocked");
while (MoreSQLData()) {
my ($i) = FetchSQLData();
push(@list2, $i);
}
$bug{'blocked'} = \@list2;
# Groups
my @groups;
if ($::usergroupset ne '0' || $bug{'groupset'} ne '0') {
my $bug_groupset = $bug{'groupset'};
if ($::driver eq 'mysql') {
SendSQL("select bit, name, description, (bit & $bug{'groupset'} != 0), " .
"(bit & $::usergroupset != 0) from groups where isbuggroup != 0 " .
# Include active groups as well as inactive groups to which
# the bug already belongs. This way the bug can be removed
# from an inactive group but can only be added to active ones.
"and ((isactive = 1 or (bit & $bug{'groupset'} != 0)) or " .
"(bit & $bug{'groupset'} != 0)) " .
"order by description");
} elsif ($::driver eq 'Pg') {
SendSQL("select group_bit, name, description, (group_bit & int8($bug{'groupset'}) != 0), " .
"(group_bit & int8($::usergroupset) != 0) from groups where isbuggroup != 0 " .
# Include active groups as well as inactive groups to which
# the bug already belongs. This way the bug can be removed
# from an inactive group but can only be added to active ones.
"and ((isactive = 1 or (group_bit & int8($bug{'groupset'}) != 0)) or " .
"(group_bit & int8($bug{'groupset'}) != 0)) " .
"order by description");
}
$user{'inallgroups'} = 1;
while (MoreSQLData()) {
my ($bit, $name, $description, $ison, $ingroup) = FetchSQLData();
# For product groups, we only want to display the checkbox if either
# (1) The bit is already set, or
# (2) The user is in the group, but either:
# (a) The group is a product group for the current product, or
# (b) The group name isn't a product name
# This means that all product groups will be skipped, but
# non-product bug groups will still be displayed.
if($ison ||
($ingroup && (($name eq $bug{'product'}) ||
(!defined $::proddesc{$name}))))
{
$user{'inallgroups'} &= $ingroup;
push (@groups, { "bit" => $bit,
"ison" => $ison,
"ingroup" => $ingroup,
"description" => $description });
}
}
# If the bug is restricted to a group, display checkboxes that allow
# the user to set whether or not the reporter
# and cc list can see the bug even if they are not members of all
# groups to which the bug is restricted.
if ($bug{'groupset'} != 0) {
$bug{'inagroup'} = 1;
# Determine whether or not the bug is always accessible by the
# reporter, QA contact, and/or users on the cc: list.
SendSQL("SELECT reporter_accessible, cclist_accessible
FROM bugs
WHERE bug_id = $id
");
($bug{'reporter_accessible'},
$bug{'cclist_accessible'}) = FetchSQLData();
}
}
$vars->{'groups'} = \@groups;
my $movers = Param("movers");
$user{'canmove'} = Param("move-enabled")
&& (defined $::COOKIE{"Bugzilla_login"})
&& ($::COOKIE{"Bugzilla_login"} =~ /\Q$movers\E/);
# User permissions
# In the below, if the person hasn't logged in ($::userid == 0), then
# we treat them as if they can do anything. That's because we don't
# know why they haven't logged in; it may just be because they don't
# use cookies. Display everything as if they have all the permissions
# in the world; their permissions will get checked when they log in
# and actually try to make the change.
$user{'canedit'} = $::userid == 0
|| $::userid == $bug{'reporter'}
|| $::userid == $bug{'qa_contact'}
|| $::userid == $bug{'assigned_to'}
|| UserInGroup("editbugs");
$user{'canconfirm'} = ($::userid == 0) || UserInGroup("canconfirm");
# Bug states
$bug{'isunconfirmed'} = ($bug{'bug_status'} eq $::unconfirmedstate);
$bug{'isopened'} = IsOpenedState($bug{'bug_status'});
# People involved with the bug
$bug{'assigned_to_email'} = DBID_to_name($bug{'assigned_to'});
$bug{'assigned_to'} = DBID_to_real_or_loginname($bug{'assigned_to'});
$bug{'reporter'} = DBID_to_real_or_loginname($bug{'reporter'});
$bug{'qa_contact'} = $bug{'qa_contact'} > 0 ?
DBID_to_name($bug{'qa_contact'}) : "";
my $ccset = new RelationSet;
$ccset->mergeFromDB("SELECT who FROM cc WHERE bug_id=$id");
my @cc = $ccset->toArrayOfStrings();
$bug{'cc'} = \@cc if $cc[0];
# Next bug in list (if there is one)
my @bug_list;
if ($::COOKIE{"BUGLIST"} && $id)
{
@bug_list = split(/:/, $::COOKIE{"BUGLIST"});
}
$vars->{'bug_list'} = \@bug_list;
$bug{'comments'} = GetComments($bug{'bug_id'});
# This is length in number of comments
$bug{'longdesclength'} = scalar(@{$bug{'comments'}});
# Add the bug and user hashes to the variables
$vars->{'bug'} = \%bug;
$vars->{'user'} = \%user;
# Generate and return the UI (HTML page) from the appropriate template.
$template->process("bug/edit.html.tmpl", $vars)
|| ThrowTemplateError($template->error());
}
1;

View File

@@ -1,206 +0,0 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<HTML>
<!--
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 the Bugzilla Bug Tracking System.
The Initial Developer of the Original Code is Netscape Communications
Corporation. Portions created by Netscape are
Copyright (C) 1998 Netscape Communications Corporation. All
Rights Reserved.
Contributor(s):
Contributor(s): Terry Weissman <terry@mozilla.org>
-->
<head>
<TITLE>A Bug's Life Cycle</TITLE>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body>
<h1 ALIGN=CENTER>A Bug's Life Cycle</h1>
The <B>status</B> and <B>resolution</B> field define and track the
life cycle of a bug.
<a name="status"></a>
<p>
<TABLE BORDER=1 CELLPADDING=4>
<TR ALIGN=CENTER VALIGN=TOP>
<TD WIDTH="50%"><H1>STATUS</H1> <TD><H1>RESOLUTION</H1>
<TR VALIGN=TOP>
<TD>The <B>status</B> field indicates the general health of a bug. Only
certain status transitions are allowed.
<TD>The <b>resolution</b> field indicates what happened to this bug.
<TR VALIGN=TOP><TD>
<DL><DT><B>
<A HREF="confirmhelp.html">UNCONFIRMED</A></B>
<DD> This bug has recently been added to the database. Nobody has
validated that this bug is true. Users who have the "canconfirm"
permission set may confirm this bug, changing its state to NEW.
Or, it may be directly resolved and marked RESOLVED.
<DT><B>NEW</B>
<DD> This bug has recently been added to the assignee's list of bugs
and must be processed. Bugs in this state may be accepted, and
become <B>ASSIGNED</B>, passed on to someone else, and remain
<B>NEW</B>, or resolved and marked <B>RESOLVED</B>.
<DT><B>ASSIGNED</B>
<DD> This bug is not yet resolved, but is assigned to the proper
person. From here bugs can be given to another person and become
<B>NEW</B>, or resolved and become <B>RESOLVED</B>.
<DT><B>REOPENED</B>
<DD>This bug was once resolved, but the resolution was deemed
incorrect. For example, a <B>WORKSFORME</B> bug is
<B>REOPENED</B> when more information shows up and the bug is now
reproducible. From here bugs are either marked <B>ASSIGNED</B>
or <B>RESOLVED</B>.
</DL>
<TD>
<DL>
<DD> No resolution yet. All bugs which are in one of these "open" states
have the resolution set to blank. All other bugs
will be marked with one of the following resolutions.
</DL>
<TR VALIGN=TOP><TD>
<DL>
<DT><B>RESOLVED</B>
<DD> A resolution has been taken, and it is awaiting verification by
QA. From here bugs are either re-opened and become
<B>REOPENED</B>, are marked <B>VERIFIED</B>, or are closed for good
and marked <B>CLOSED</B>.
<DT><B>VERIFIED</B>
<DD> QA has looked at the bug and the resolution and agrees that the
appropriate resolution has been taken. Bugs remain in this state
until the product they were reported against actually ships, at
which point they become <B>CLOSED</B>.
<DT><B>CLOSED</B>
<DD> The bug is considered dead, the resolution is correct. Any zombie
bugs who choose to walk the earth again must do so by becoming
<B>REOPENED</B>.
</DL>
<TD>
<DL>
<DT><B>FIXED</B>
<DD> A fix for this bug is checked into the tree and tested.
<DT><B>INVALID</B>
<DD> The problem described is not a bug
<DT><B>WONTFIX</B>
<DD> The problem described is a bug which will never be fixed.
<DT><B>LATER</B>
<DD> The problem described is a bug which will not be fixed in this
version of the product.
<DT><B>REMIND</B>
<DD> The problem described is a bug which will probably not be fixed in this
version of the product, but might still be.
<DT><B>DUPLICATE</B>
<DD> The problem is a duplicate of an existing bug. Marking a bug
duplicate requires the bug# of the duplicating bug and will at
least put that bug number in the description field.
<DT><B>WORKSFORME</B>
<DD> All attempts at reproducing this bug were futile, reading the
code produces no clues as to why this behavior would occur. If
more information appears later, please re-assign the bug, for
now, file it.
</DL>
</TABLE>
<H1>Other Fields</H1>
<table border=1 cellpadding=4><tr><td>
<h2><a name="severity">Severity</a></h2>
This field describes the impact of a bug.
<p>
<p>
<table>
<tr><th>Blocker</th><td>Blocks development and/or testing work
<tr><th>Critical</th><td>crashes, loss of data, severe memory leak
<tr><th>Major</th><td>major loss of function
<tr><th>Minor</th><td>minor loss of function, or other problem where easy workaround is present
<tr><th>Trivial</th><td>cosmetic problem like misspelled words or misaligned text
<tr><th>Enhancement</th><td>Request for enhancement
</table>
</td><td>
<h2><a name="priority">Priority</a></h2>
This field describes the importance and order in which a bug should be
fixed. This field is utilized by the programmers/engineers to
prioritize their work to be done. The available priorities are:
<p>
<p>
<table>
<tr><th>P1</th><td>Most important
<tr><th>P2</th><td>
<tr><th>P3</th><td>
<tr><th>P4</th><td>
<tr><th>P5</th><td>Least important
</table>
</tr></table>
<h2><a name="rep_platform">Platform</a></h2>
This is the hardware platform against which the bug was reported. Legal
platforms include:
<UL>
<LI> All (happens on all platform; cross-platform bug)
<LI> Macintosh
<LI> PC
<LI> Sun
<LI> HP
</UL>
<b>Note:</b> Selecting the option "All" does not select bugs assigned against all platforms. It
merely selects bugs that <b>occur</b> on all platforms.
<h2><a name="op_sys">Operating System</a></h2>
This is the operating system against which the bug was reported. Legal
operating systems include:
<UL>
<LI> All (happens on all operating systems; cross-platform bug)
<LI> Windows 95
<LI> Mac System 8.0
<LI> Linux
</UL>
Note that the operating system implies the platform, but not always.
For example, Linux can run on PC and Macintosh and others.
<h2><a name="assigned_to">Assigned To</a></h2>
This is the person in charge of resolving the bug. Every time this
field changes, the status changes to <B>NEW</B> to make it easy to see
which new bugs have appeared on a person's list.
The default status for queries is set to NEW, ASSIGNED and REOPENED. When
searching for bugs that have been resolved or verified, remember to set the
status field appropriately.
<hr>
<!-- hhmts start -->
Last modified: Sun Apr 14 12:51:23 EST 2002
<!-- hhmts end -->
</body> </html>

File diff suppressed because it is too large Load Diff

View File

@@ -1,392 +0,0 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=iso-8859-1">
<title>Bug Writing Guidelines</title>
</head>
<body>
<center>
<h1>Bug Writing Guidelines</h1>
</center>
<h3>Why You Should Read This</h3>
<blockquote>
<p>Simply put, the more effectively you report a bug, the more
likely an engineer will actually fix it.</p>
<p>These guidelines are a general
tutorial to teach novice and intermediate bug reporters how to compose effective bug reports. Not every sentence may precisely apply to
your software project.</p>
</blockquote>
<h3>How to Write a Useful Bug Report</h3>
<blockquote>
<p>Useful bug reports are ones that get bugs fixed. A useful bug
report normally has two qualities:</p>
<ol>
<li><b>Reproducible.</b> If an engineer can't see the bug herself to prove that it exists, she'll probably stamp your bug report "WORKSFORME" or "INVALID" and move on to the next bug. Every detail you can provide helps.<br>
<br>
</li>
<li><b>Specific.</b> The quicker the engineer can isolate the bug
to a specific area, the more likely she'll expediently fix it.
(If a programmer or tester has to decypher a bug, they may spend
more time cursing the submitter than solving the problem.)
<br>
<br>
[ <a href="#tips" name="Anchor">Tell Me More</a> ]
</li>
</ol>
<p>Let's say the application you're testing is a web browser. You
crash at foo.com, and want to write up a bug report:</p>
<blockquote>
<p><b>BAD:</b> "My browser crashed. I think I was on www.foo.com. I play golf with Bill Gates, so you better fix this problem, or I'll report you to him. By the way, your Back icon looks like a squashed rodent. UGGGLY. And my grandmother's home page is all messed up in your browser. Thx 4 UR help."
</p>
<p>
<b>GOOD:</b> "I crashed each time I went to www.foo.com, using
the 2002-02-25 build on a Windows 2000 system. I also
rebooted into Linux, and reproduced this problem using the 2002-02-24
Linux build.
</p>
<p>
It again crashed each time upon drawing the Foo banner at the top
of the page. I broke apart the page, and discovered that the
following image link will crash the application reproducibly,
unless you remove the "border=0" attribute:
</p>
<p>
<tt>&lt;IMG SRC="http://www.foo.com/images/topics/topicfoos.gif"
width="34" height="44" border="0" alt="News"&gt;</tt>
</p>
</blockquote>
</blockquote>
<h3>How to Enter your Useful Bug Report into Bugzilla:</h3>
<blockquote>
<p>Before you enter your bug, use Bugzilla's
<a href="query.cgi">search page</a> to determine whether the defect you've discovered is a known, already-reported bug. If your bug is the 37th duplicate of a known issue, you're more likely to annoy the engineer. (Annoyed
engineers fix fewer bugs.)
</p>
<p>
Next, be sure to reproduce your bug using a recent
build. Engineers tend to be most interested in problems affecting
the code base that they're actively working on. After all, the bug you're reporting
may already be fixed.
</p>
<p>
If you've discovered a new bug using a current build, report it in
Bugzilla:
</p>
<ol>
<li>From your Bugzilla main page, choose
"<a href="enter_bug.cgi">Enter a new bug</a>".</li>
<li>Select the product that you've found a bug in.</li>
<li>Enter your e-mail address, password, and press the "Login"
button. (If you don't yet have a password, leave the password field empty,
and press the "E-mail me a password" button instead.
You'll quickly receive an e-mail message with your password.)</li>
</ol>
<p>Now, fill out the form. Here's what it all means:</p>
<p><b>Where did you find the bug?</b></p>
<blockquote>
<p><b>Product: In which product did you find the bug?</b><br>
You just specified this on the last page, so you can't edit it here.</p>
<p><b>Version: In which product version did you find the
bug?</b><br>
(If applicable)</p>
<p><b>Component: In which component does the bug exist?</b><br>
Bugzilla requires that you select a component to enter a bug. (Not sure which to choose?
Click on the Component link. You'll see a description of each component, to help you make the best choice.)</p>
<p><b>OS: On which Operating System (OS) did you find this bug?</b>
(e.g. Linux, Windows 2000, Mac OS 9.)<br>
If you know the bug happens on all OSs, choose 'All'. Otherwise,
select the OS that you found the bug on, or "Other" if your OS
isn't listed.</p>
</blockquote>
<p><b>How important is the bug?</b></p>
<blockquote>
<p><b>Severity: How damaging is the bug?</b><br>
This item defaults to 'normal'. If you're not sure what severity your bug deserves, click on the Severity link.
You'll see a description of each severity rating. <br>
</p>
</blockquote>
<p><b>Who will be following up on the bug?</b></p>
<blockquote>
<p><b>Assigned To: Which engineer should be responsible for fixing
this bug?</b><br>
Bugzilla will automatically assign the bug to a default engineer
upon submitting a bug report. If you'd prefer to directly assign the bug to
someone else, enter their e-mail address into this field. (To see the list of
default engineers for each component, click on the Component
link.)</p>
<p><b>Cc: Who else should receive e-mail updates on changes to this
bug?</b><br>
List the full e-mail addresses of other individuals who should
receive an e-mail update upon every change to the bug report. You
can enter as many e-mail addresses as you'd like, separated by spaces or commas, as long as those
people have Bugzilla accounts.</p>
</blockquote>
<p><b>What else can you tell the engineer about the bug?</b></p>
<blockquote>
<p><b>Summary:</b> <b>How would you describe the bug, in
approximately 60 or fewer characters?</b><br>
A good summary should <b>quickly and uniquely identify a bug
report</b>. Otherwise, an engineer cannot meaningfully identify
your bug by its summary, and will often fail to pay attention to
your bug report when skimming through a 10 page bug list.<br>
<br>
A useful summary might be
"<tt>PCMCIA install fails on Tosh Tecra 780DVD w/ 3c589C</tt>".
"<tt>Software fails</tt>" or "<tt>install problem</tt>" would be
examples of a bad summary.<br>
<br>
[ <a href="#summary">Tell Me More</a> ]<br>
<br>
<b>Description: </b><br>
Please provide a detailed problem report in this field.
Your bug's recipients will most likely expect the following information:</p>
<blockquote>
<p><b>Overview Description:</b> More detailed expansion of
summary.</p>
<blockquote>
<pre>
Drag-selecting any page crashes Mac builds in NSGetFactory
</pre>
</blockquote>
<p><b>Steps to Reproduce:</b> Minimized, easy-to-follow steps that will
trigger the bug. Include any special setup steps.</p>
<blockquote>
<pre>
1) View any web page. (I used the default sample page,
resource:/res/samples/test0.html)
2) Drag-select the page. (Specifically, while holding down
the mouse button, drag the mouse pointer downwards from any
point in the browser's content region to the bottom of the
browser's content region.)
</pre>
</blockquote>
<p>
<b>Actual Results:</b> What the application did after performing
the above steps.
</p>
<blockquote>
<pre>
The application crashed. Stack crawl appended below from MacsBug.
</pre>
</blockquote>
<p><b>Expected Results:</b> What the application should have done,
were the bug not present.</p>
<blockquote>
<pre>
The window should scroll downwards. Scrolled content should be selected.
(Or, at least, the application should not crash.)
</pre>
</blockquote>
<p><b>Build Date &amp; Platform:</b> Date and platform of the build
that you first encountered the bug in.</p>
<blockquote>
<pre>
Build 2002-03-15 on Mac OS 9.0
</pre>
</blockquote>
<p><b>Additional Builds and Platforms:</b> Whether or not the bug
takes place on other platforms (or browsers, if applicable).</p>
<blockquote>
<pre>
- Also Occurs On
Mozilla (2002-03-15 build on Windows NT 4.0)
- Doesn't Occur On
Mozilla (2002-03-15 build on Red Hat Linux; feature not supported)
Internet Explorer 5.0 (shipping build on Windows NT 4.0)
Netscape Communicator 4.5 (shipping build on Mac OS 9.0)
</pre>
</blockquote>
<p><b>Additional Information:</b> Any other debugging information.
For crashing bugs:</p>
<ul>
<li><b>Win32:</b> if you receive a Dr. Watson error, please note
the type of the crash, and the module that the application crashed
in. (e.g. access violation in apprunner.exe)</li>
<li><b>Mac OS:</b> if you're running MacsBug, please provide the
results of a <b>how</b> and an <b>sc</b>:</li>
</ul>
<blockquote>
<pre>
*** MACSBUG STACK CRAWL OF CRASH (Mac OS)
Calling chain using A6/R1 links
Back chain ISA Caller
00000000 PPC 0BA85E74
03AEFD80 PPC 0B742248
03AEFD30 PPC 0B50FDDC NSGetFactory+027FC
PowerPC unmapped memory exception at 0B512BD0 NSGetFactory+055F0
</pre>
</blockquote>
</blockquote>
</blockquote>
<p>You're done!<br>
<br>
After double-checking your entries for any possible errors, press
the "Commit" button, and your bug report will now be in the
Bugzilla database.<br>
</p>
</blockquote>
<hr>
<h3>More Information on Writing Good Bugs</h3>
<blockquote>
<p><b><a name="tips"></a> 1. General Tips for a Useful Bug
Report</b>
</p>
<blockquote>
<p>
<b>Use an explicit structure, so your bug reports are easy to
skim.</b> Bug report users often need immediate access to specific
sections of your bug. If your Bugzilla installation supports the
Bugzilla Helper, use it.
</p>
<p>
<b>Avoid cuteness if it costs clarity.</b> Nobody will be laughing
at your funny bug title at 3:00 AM when they can't remember how to
find your bug.
</p>
<p>
<b>One bug per report.</b> Completely different people typically
fix, verify, and prioritize different bugs. If you mix a handful of
bugs into a single report, the right people probably won't discover
your bugs in a timely fashion, or at all. Certain bugs are also
more important than others. It's impossible to prioritize a bug
report when it contains four different issues, all of differing
importance.
</p>
<p>
<b>No bug is too trivial to report.</b> Unless you're reading the
source code, you can't see actual software bugs, like a dangling
pointer -- you'll see their visible manifestations, such as the
segfault when the application finally crashes. Severe software
problems can manifest themselves in superficially trivial ways.
File them anyway.<br>
</p>
</blockquote>
<p><b><a name="summary"></a>2. How and Why to Write Good Bug Summaries</b>
</p>
<blockquote>
<p><b>You want to make a good first impression on the bug
recipient.</b> Just like a New York Times headline guides readers
towards a relevant article from dozens of choices, will your bug summary
suggest that your bug report is worth reading from dozens or hundreds of
choices?
</p>
<p>
Conversely, a vague bug summary like <tt>install problem</tt> forces anyone
reviewing installation bugs to waste time opening up your bug to
determine whether it matters.
</p>
<p>
<b>Your bug will often be searched by its summary.</b> Just as
you'd find web pages with Google by searching by keywords through
intuition, so will other people locate your bugs. Descriptive bug
summaries are naturally keyword-rich, and easier to find.
</p>
<p>
For example, you'll find a bug titled "<tt>Dragging icons from List View to
gnome-terminal doesn't paste path</tt>" if you search on "List",
"terminal", or "path". Those search keywords wouldn't have found a
bug titled "<tt>Dragging icons
doesn't paste</tt>".
</p>
<p>
Ask yourself, "Would someone understand my bug from just this
summary?" If so, you've written a fine summary.
</p>
<p><b>Don't write titles like these:</b></p>
<ol>
<li>"Can't install" - Why can't you install? What happens when you
try to install?</li>
<li>"Severe Performance Problems" - ...and they occur when you do
what?</li>
<li>"back button does not work" - Ever? At all?</li>
</ol>
<p><b>Good bug titles:</b></p>
<ol>
<li>"1.0 upgrade installation fails if Mozilla M18 package present"
- Explains problem and the context.</li>
<li>"RPM 4 installer crashes if launched on Red Hat 6.2 (RPM 3)
system" - Explains what happens, and the context.</li>
</ol>
</blockquote>
</blockquote>
<p>(Written and maintained by
<a href="http://www.prometheus-music.com/eli">Eli Goldberg</a>. Claudius
Gayle, Gervase Markham, Peter Mock, Chris Pratt, Tom Schutter and Chris Yeh also
contributed significant changes. Constructive
<a href="mailto:eli@prometheus-music.com">suggestions</a> welcome.)</p>
</body>
</html>

View File

@@ -1,46 +0,0 @@
<!ELEMENT bugzilla (bug+)>
<!ATTLIST bugzilla
version CDATA #REQUIRED
urlbase CDATA #REQUIRED
maintainer CDATA #REQUIRED
exporter CDATA #IMPLIED
>
<!ELEMENT bug (bug_id, (bug_status, product, priority, version, rep_platform, assigned_to, delta_ts, component, reporter, target_milestone?, bug_severity, creation_ts, qa_contact?, op_sys, resolution?, bug_file_loc?, short_desc?, keywords*, status_whiteboard?, dependson*, blocks*, cc*, long_desc*, attachment*)?)>
<!ATTLIST bug
error (NotFound | NotPermitted | InvalidBugId) #IMPLIED
>
<!ELEMENT bug_id (#PCDATA)>
<!ELEMENT exporter (#PCDATA)>
<!ELEMENT urlbase (#PCDATA)>
<!ELEMENT bug_status (#PCDATA)>
<!ELEMENT product (#PCDATA)>
<!ELEMENT priority (#PCDATA)>
<!ELEMENT version (#PCDATA)>
<!ELEMENT rep_platform (#PCDATA)>
<!ELEMENT assigned_to (#PCDATA)>
<!ELEMENT delta_ts (#PCDATA)>
<!ELEMENT component (#PCDATA)>
<!ELEMENT reporter (#PCDATA)>
<!ELEMENT target_milestone (#PCDATA)>
<!ELEMENT bug_severity (#PCDATA)>
<!ELEMENT creation_ts (#PCDATA)>
<!ELEMENT qa_contact (#PCDATA)>
<!ELEMENT status_whiteboard (#PCDATA)>
<!ELEMENT op_sys (#PCDATA)>
<!ELEMENT resolution (#PCDATA)>
<!ELEMENT bug_file_loc (#PCDATA)>
<!ELEMENT short_desc (#PCDATA)>
<!ELEMENT keywords (#PCDATA)>
<!ELEMENT dependson (#PCDATA)>
<!ELEMENT blocks (#PCDATA)>
<!ELEMENT cc (#PCDATA)>
<!ELEMENT long_desc (who, bug_when, thetext)>
<!ELEMENT who (#PCDATA)>
<!ELEMENT bug_when (#PCDATA)>
<!ELEMENT thetext (#PCDATA)>
<!ELEMENT attachment (attachid, date, desc, type?, data?)>
<!ELEMENT attachid (#PCDATA)>
<!ELEMENT date (#PCDATA)>
<!ELEMENT desc (#PCDATA)>
<!ELEMENT type (#PCDATA)>
<!ELEMENT data (#PCDATA)>

View File

@@ -1,39 +0,0 @@
#!/usr/bonsaitools/bin/perl -wT
# -*- Mode: perl; indent-tabs-mode: nil -*-
#
# 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 the Bugzilla Bug Tracking System.
#
# The Initial Developer of the Original Code is Netscape Communications
# Corporation. Portions created by Netscape are
# Copyright (C) 1998 Netscape Communications Corporation. All
# Rights Reserved.
#
# Contributor(s): Terry Weissman <terry@mozilla.org>
use strict;
print q{Content-type: text/html
<HTML>
<HEAD>
<META HTTP-EQUIV="Refresh"
CONTENT="0; URL=userprefs.cgi">
</HEAD>
<BODY>
This URL is obsolete. Forwarding you to the correct one.
<P>
Going to <A HREF="userprefs.cgi">userprefs.cgi</A>
<BR>
</BODY>
</HTML>
}

File diff suppressed because it is too large Load Diff

Some files were not shown because too many files have changed in this diff Show More