~ubuntu-branches/ubuntu/precise/kompozer/precise

« back to all changes in this revision

Viewing changes to mozilla/extensions/webservices/proxy/src/wspprivate.h

  • Committer: Bazaar Package Importer
  • Author(s): Anthony Yarusso
  • Date: 2007-08-27 01:11:03 UTC
  • Revision ID: james.westby@ubuntu.com-20070827011103-2jgf4s6532gqu2ka
Tags: upstream-0.7.10
ImportĀ upstreamĀ versionĀ 0.7.10

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
 
2
/* ***** BEGIN LICENSE BLOCK *****
 
3
 * Version: NPL 1.1/GPL 2.0/LGPL 2.1
 
4
 *
 
5
 * The contents of this file are subject to the Netscape Public License
 
6
 * Version 1.1 (the "License"); you may not use this file except in
 
7
 * compliance with the License. You may obtain a copy of the License at
 
8
 * http://www.mozilla.org/NPL/
 
9
 *
 
10
 * Software distributed under the License is distributed on an "AS IS" basis,
 
11
 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
 
12
 * for the specific language governing rights and limitations under the
 
13
 * License.
 
14
 *
 
15
 * The Original Code is mozilla.org code.
 
16
 *
 
17
 * The Initial Developer of the Original Code is 
 
18
 * Netscape Communications Corporation.
 
19
 * Portions created by the Initial Developer are Copyright (C) 2001
 
20
 * the Initial Developer. All Rights Reserved.
 
21
 *
 
22
 * Contributor(s):
 
23
 *   Vidur Apparao (vidur@netscape.com) (Original author)
 
24
 *   John Bandhauer (jband@netscape.com)
 
25
 *
 
26
 *
 
27
 * Alternatively, the contents of this file may be used under the terms of
 
28
 * either the GNU General Public License Version 2 or later (the "GPL"), or
 
29
 * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
 
30
 * in which case the provisions of the GPL or the LGPL are applicable instead
 
31
 * of those above. If you wish to allow use of your version of this file only
 
32
 * under the terms of either the GPL or the LGPL, and not to allow others to
 
33
 * use your version of this file under the terms of the NPL, indicate your
 
34
 * decision by deleting the provisions above and replace them with the notice
 
35
 * and other provisions required by the GPL or the LGPL. If you do not delete
 
36
 * the provisions above, a recipient may use your version of this file under
 
37
 * the terms of any one of the NPL, the GPL or the LGPL.
 
38
 *
 
39
 * ***** END LICENSE BLOCK ***** */
 
40
 
 
41
#ifndef __wspprivate_h__
 
42
#define __wspprivate_h__
 
43
 
 
44
// XPCOM includes
 
45
#include "nsCOMPtr.h"
 
46
#include "nsCOMArray.h"
 
47
#include "nsIPropertyBag.h"
 
48
#include "nsIException.h"
 
49
#include "nsIExceptionService.h"
 
50
#include "nsIServiceManager.h"
 
51
#include "nsAString.h"
 
52
 
 
53
// SOAP includes
 
54
#include "nsISOAPCall.h"
 
55
#include "nsISOAPResponse.h"
 
56
#include "nsISOAPResponseListener.h"
 
57
#include "nsISOAPCallCompletion.h"
 
58
#include "nsISOAPFault.h"
 
59
#include "nsSOAPUtils.h"
 
60
 
 
61
// interface info includes
 
62
#include "xptcall.h"
 
63
#include "nsIInterfaceInfo.h"
 
64
 
 
65
// WSDL includes
 
66
#include "nsIWSDL.h"
 
67
#include "nsIWSDLLoader.h"
 
68
#include "nsIWSDLSOAPBinding.h"
 
69
 
 
70
// iix includes
 
71
#include "nsIGenericInterfaceInfoSet.h"
 
72
 
 
73
// Proxy includes
 
74
#include "nsIWebServiceProxy.h"
 
75
#include "nsIWSPInterfaceInfoService.h"
 
76
 
 
77
// Forward decls
 
78
class WSPCallContext;
 
79
 
 
80
class WSPFactory : public nsIWebServiceProxyFactory
 
81
{
 
82
public:
 
83
  WSPFactory();
 
84
  virtual ~WSPFactory();
 
85
 
 
86
  NS_DECL_ISUPPORTS
 
87
  NS_DECL_NSIWEBSERVICEPROXYFACTORY  
 
88
 
 
89
  static nsresult C2XML(const nsACString& aCIdentifier,
 
90
                        nsAString& aXMLIdentifier);
 
91
  static void XML2C(const nsAString& aXMLIndentifier,
 
92
                    nsACString& aCIdentifier);
 
93
};
 
94
 
 
95
class WSPProxy : public nsXPTCStubBase,
 
96
                 public nsIWebServiceProxy,
 
97
                 public nsIClassInfo
 
98
{
 
99
public:
 
100
  WSPProxy();
 
101
  virtual ~WSPProxy();
 
102
 
 
103
  NS_DECL_ISUPPORTS
 
104
  NS_DECL_NSIWEBSERVICEPROXY
 
105
  NS_DECL_NSICLASSINFO
 
106
 
 
107
  // Would be nice to have a NS_DECL_NSXPTCSTUBBASE
 
108
  NS_IMETHOD CallMethod(PRUint16 methodIndex,
 
109
                        const nsXPTMethodInfo* info,
 
110
                        nsXPTCMiniVariant* params);
 
111
  NS_IMETHOD GetInterfaceInfo(nsIInterfaceInfo** info);
 
112
 
 
113
  void GetListenerInterfaceInfo(nsIInterfaceInfo** aInfo);
 
114
  void CallCompleted(WSPCallContext* aContext);
 
115
 
 
116
  static NS_METHOD
 
117
  Create(nsISupports* outer, const nsIID& aIID, void* *aInstancePtr);
 
118
 
 
119
  static nsresult XPTCMiniVariantToVariant(uint8 aTypeTag,
 
120
                                           nsXPTCMiniVariant aResult,
 
121
                                           nsIInterfaceInfo* aInterfaceInfo,
 
122
                                           nsIVariant** aVariant);
 
123
  static nsresult ArrayXPTCMiniVariantToVariant(uint8 aTypeTag,
 
124
                                                nsXPTCMiniVariant aResult,
 
125
                                                PRUint32 aLength,
 
126
                                                nsIInterfaceInfo* aIfaceInfo,
 
127
                                                nsIVariant** aVariant);
 
128
 
 
129
  static nsresult VariantToValue(uint8 aTypeTag,
 
130
                                 void* aValue,
 
131
                                 nsIInterfaceInfo* aInterfaceInfo,
 
132
                                 nsIVariant* aProperty);
 
133
  static nsresult VariantToArrayValue(uint8 aTypeTag,
 
134
                                      nsXPTCMiniVariant* aResult,
 
135
                                      nsIInterfaceInfo* aInterfaceInfo,
 
136
                                      nsIVariant* aProperty);
 
137
 
 
138
  static nsresult ParameterToVariant(nsIInterfaceInfo* aInterfaceInfo,
 
139
                                     PRUint32 aMethodIndex,
 
140
                                     const nsXPTParamInfo* aParamInfo,
 
141
                                     nsXPTCMiniVariant aMiniVariant,
 
142
                                     PRUint32 aArrayLength,
 
143
                                     nsIVariant** aVariant);
 
144
  static nsresult VariantToInParameter(nsIInterfaceInfo* aInterfaceInfo,
 
145
                                       PRUint32 aMethodIndex,
 
146
                                       const nsXPTParamInfo* aParamInfo,
 
147
                                       nsIVariant* aVariant,
 
148
                                       nsXPTCVariant* aXPTCVariant);
 
149
  static nsresult VariantToOutParameter(nsIInterfaceInfo* aInterfaceInfo,
 
150
                                        PRUint32 aMethodIndex,
 
151
                                        const nsXPTParamInfo* aParamInfo,
 
152
                                        nsIVariant* aVariant,
 
153
                                        nsXPTCMiniVariant* aMiniVariant);
 
154
  static nsresult WrapInPropertyBag(nsISupports* aInstance,
 
155
                                    nsIInterfaceInfo* aInterfaceInfo,
 
156
                                    nsIPropertyBag** aPropertyBag);
 
157
  static nsresult WrapInComplexType(nsIPropertyBag* aPropertyBag,
 
158
                                    nsIInterfaceInfo* aInterfaceInfo,
 
159
                                    nsISupports** aComplexType);
 
160
 
 
161
 
 
162
protected:
 
163
  nsresult GetInterfaceName(PRBool listener, char** retval);
 
164
 
 
165
protected:
 
166
  nsCOMPtr<nsIWSDLPort> mPort;
 
167
  nsCOMPtr<nsIInterfaceInfo> mPrimaryInterface;
 
168
  nsCOMPtr<nsIInterfaceInfoManager> mInterfaceInfoManager;
 
169
  nsString mQualifier;
 
170
  PRBool mIsAsync;
 
171
  nsCOMArray<nsIWebServiceCallContext> mPendingCalls;
 
172
  const nsIID* mIID;
 
173
  nsCOMPtr<nsISupports> mAsyncListener;
 
174
  nsCOMPtr<nsIInterfaceInfo> mListenerInterfaceInfo;
 
175
  nsCOMPtr<nsIScriptableInterfaces> mInterfaces;
 
176
};
 
177
 
 
178
class WSPCallContext : public nsIWebServiceSOAPCallContext,
 
179
                       public nsISOAPResponseListener
 
180
{
 
181
public:
 
182
  WSPCallContext(WSPProxy* aProxy,
 
183
                 nsISOAPCall* aSOAPCall,
 
184
                 const nsAString& aMethodName,
 
185
                 nsIWSDLOperation* aOperation);
 
186
  virtual ~WSPCallContext();
 
187
 
 
188
  NS_DECL_ISUPPORTS
 
189
  NS_DECL_NSIWEBSERVICECALLCONTEXT
 
190
  NS_DECL_NSIWEBSERVICESOAPCALLCONTEXT
 
191
  NS_DECL_NSISOAPRESPONSELISTENER
 
192
  
 
193
  nsresult CallAsync(PRUint32 aListenerMethodIndex,
 
194
                     nsISupports* aListener);
 
195
  nsresult CallSync(PRUint32 aMethodIndex,
 
196
                    nsXPTCMiniVariant* params);
 
197
 
 
198
protected:
 
199
  nsresult CallCompletionListener();
 
200
 
 
201
protected:
 
202
  WSPProxy* mProxy;
 
203
  nsCOMPtr<nsISOAPCall> mCall;
 
204
  nsString mMethodName;
 
205
  nsCOMPtr<nsIWSDLOperation> mOperation;
 
206
  nsCOMPtr<nsISOAPCallCompletion> mCompletion;
 
207
  nsCOMPtr<nsISOAPResponse> mResponse;
 
208
  nsresult mStatus;
 
209
  nsCOMPtr<nsIException> mException;
 
210
  nsCOMPtr<nsISupports> mAsyncListener;
 
211
  PRUint32 mListenerMethodIndex;
 
212
};
 
213
 
 
214
class WSPException : public nsIException 
 
215
{
 
216
public:
 
217
  WSPException(nsISOAPFault* aFault, nsresult aStatus);
 
218
  WSPException(nsresult aStatus, const char* aMsg, nsISupports* aData);
 
219
  virtual ~WSPException();
 
220
 
 
221
  NS_DECL_ISUPPORTS
 
222
  NS_DECL_NSIEXCEPTION
 
223
 
 
224
protected:
 
225
  nsCOMPtr<nsISOAPFault> mFault;
 
226
  nsCOMPtr<nsISupports> mData;
 
227
  nsresult mStatus;
 
228
  char* mMsg;
 
229
};
 
230
 
 
231
class WSPComplexTypeWrapper : public nsIWebServiceComplexTypeWrapper,
 
232
                              public nsIPropertyBag
 
233
{
 
234
public:
 
235
  WSPComplexTypeWrapper();
 
236
  virtual ~WSPComplexTypeWrapper();
 
237
 
 
238
  NS_DECL_ISUPPORTS
 
239
  NS_DECL_NSIPROPERTYBAG
 
240
  NS_DECL_NSIWEBSERVICECOMPLEXTYPEWRAPPER
 
241
 
 
242
  static NS_METHOD
 
243
  Create(nsISupports* outer, const nsIID& aIID, void* *aInstancePtr);
 
244
 
 
245
  nsresult GetPropertyValue(PRUint32 aMethodIndex,
 
246
                            const nsXPTMethodInfo* aMethodInfo,
 
247
                            nsIVariant** _retval);
 
248
 
 
249
protected:
 
250
  nsCOMPtr<nsISupports> mComplexTypeInstance;
 
251
  nsCOMPtr<nsIInterfaceInfo> mInterfaceInfo;
 
252
};
 
253
 
 
254
class WSPPropertyBagWrapper : public nsXPTCStubBase,
 
255
                              public nsIWebServicePropertyBagWrapper,
 
256
                              public nsIClassInfo
 
257
{
 
258
public:
 
259
  WSPPropertyBagWrapper();
 
260
  virtual ~WSPPropertyBagWrapper();
 
261
 
 
262
  NS_DECL_ISUPPORTS
 
263
  NS_DECL_NSIWEBSERVICEPROPERTYBAGWRAPPER
 
264
  NS_DECL_NSICLASSINFO
 
265
 
 
266
  // Would be nice to have a NS_DECL_NSXPTCSTUBBASE
 
267
  NS_IMETHOD CallMethod(PRUint16 methodIndex,
 
268
                        const nsXPTMethodInfo* info,
 
269
                        nsXPTCMiniVariant* params);
 
270
  NS_IMETHOD GetInterfaceInfo(nsIInterfaceInfo** info);
 
271
 
 
272
  static NS_METHOD
 
273
  Create(nsISupports* outer, const nsIID& aIID, void* *aInstancePtr);
 
274
 
 
275
protected:
 
276
  nsCOMPtr<nsIPropertyBag> mPropertyBag;
 
277
  nsCOMPtr<nsIInterfaceInfo> mInterfaceInfo;
 
278
  const nsIID* mIID;
 
279
};
 
280
 
 
281
class nsWSPInterfaceInfoService : public nsIWSPInterfaceInfoService
 
282
{
 
283
public:
 
284
  NS_DECL_ISUPPORTS
 
285
  NS_DECL_NSIWSPINTERFACEINFOSERVICE
 
286
 
 
287
  nsWSPInterfaceInfoService();
 
288
  virtual ~nsWSPInterfaceInfoService();
 
289
};
 
290
 
 
291
#define NS_WEBSERVICECALLCONTEXT_CLASSID          \
 
292
{ /* a42e9bf3-6bae-4c59-8f76-9dc175eec5b1 */      \
 
293
 0xa42e9bf3, 0x6bae, 0x4c59,                      \
 
294
 {0x8f, 0x76, 0x9d, 0xc1, 0x75, 0xee, 0xc5, 0xb1}}
 
295
#define NS_WEBSERVICECALLCONTEXT_CONTRACTID "@mozilla.org/xmlextras/proxy/webservicecallcontext;1"
 
296
#define NS_WEBSERVICEEXCEPTION_CLASSID            \
 
297
{ /* 07c2bf7b-376e-4629-b9c0-dbb17630b98d */      \
 
298
 0x07c2bf7b, 0x376e, 0x4629,                      \
 
299
 {0xb9, 0xc0, 0xdb, 0xb1, 0x76, 0x30, 0xb9, 0x8d}}
 
300
#define NS_WEBSERVICEEXCEPTION_CONTRACTID "@mozilla.org/xmlextras/proxy/webserviceexception;1"
 
301
 
 
302
#endif // __wspprivate_h__