1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /* ***** BEGIN LICENSE BLOCK *****
3 * Version: MPL 1.1/GPL 2.0/LGPL 2.1
5 * The contents of this file are subject to the Mozilla Public License Version
6 * 1.1 (the "License"); you may not use this file except in compliance with
7 * the License. You may obtain a copy of the License at
8 * http://www.mozilla.org/MPL/
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
15 * The Original Code is mozilla.org code.
17 * The Initial Developer of the Original Code is
18 * Netscape Communications Corporation.
19 * Portions created by the Initial Developer are Copyright (C) 1998
20 * the Initial Developer. All Rights Reserved.
24 * Alternatively, the contents of this file may be used under the terms of
25 * either the GNU General Public License Version 2 or later (the "GPL"), or
26 * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
27 * in which case the provisions of the GPL or the LGPL are applicable instead
28 * of those above. If you wish to allow use of your version of this file only
29 * under the terms of either the GPL or the LGPL, and not to allow others to
30 * use your version of this file under the terms of the MPL, indicate your
31 * decision by deleting the provisions above and replace them with the notice
32 * and other provisions required by the GPL or the LGPL. If you do not delete
33 * the provisions above, a recipient may use your version of this file under
34 * the terms of any one of the MPL, the GPL or the LGPL.
36 * ***** END LICENSE BLOCK ***** */
38 #ifndef nsISecureEnv_h___
39 #define nsISecureEnv_h___
41 #include "nsISupports.h"
42 #include "nsIFactory.h"
43 #include "nsISecurityContext.h"
60 #define NS_ISECUREENV_IID \
61 { /* ca9148d0-598a-11d2-a1d4-00805f8f694d */ \
65 {0xa1, 0xd4, 0x00, 0x80, 0x5f, 0x8f, 0x69, 0x4d } \
68 class nsISecureEnv
: public nsISupports
{
70 NS_DECLARE_STATIC_IID_ACCESSOR(NS_ISECUREENV_IID
)
73 * Create new Java object in LiveConnect.
75 * @param clazz -- Java Class object.
76 * @param methodID -- Method id
77 * @param args -- arguments for invoking the constructor.
78 * @param result -- return new Java object.
79 * @param ctx -- security context
81 NS_IMETHOD
NewObject(/*[in]*/ jclass clazz
,
82 /*[in]*/ jmethodID methodID
,
83 /*[in]*/ jvalue
*args
,
84 /*[out]*/ jobject
* result
,
85 /*[in]*/ nsISecurityContext
* ctx
= NULL
) = 0;
88 * Invoke method on Java object in LiveConnect.
90 * @param type -- Return type
91 * @param obj -- Java object.
92 * @param methodID -- method id
93 * @param args -- arguments for invoking the constructor.
94 * @param result -- return result of invocation.
95 * @param ctx -- security context
97 NS_IMETHOD
CallMethod(/*[in]*/ jni_type type
,
99 /*[in]*/ jmethodID methodID
,
100 /*[in]*/ jvalue
*args
,
101 /*[out]*/ jvalue
* result
,
102 /*[in]*/ nsISecurityContext
* ctx
= NULL
) = 0;
105 * Invoke non-virtual method on Java object in LiveConnect.
107 * @param type -- Return type
108 * @param obj -- Java object.
109 * @param clazz -- Class object
110 * @param methodID -- method id
111 * @param args -- arguments for invoking the constructor.
112 * @param ctx -- security context
113 * @param result -- return result of invocation.
115 NS_IMETHOD
CallNonvirtualMethod(/*[in]*/ jni_type type
,
116 /*[in]*/ jobject obj
,
117 /*[in]*/ jclass clazz
,
118 /*[in]*/ jmethodID methodID
,
119 /*[in]*/ jvalue
*args
,
120 /*[out]*/ jvalue
* result
,
121 /*[in]*/ nsISecurityContext
* ctx
= NULL
) = 0;
124 * Get a field on Java object in LiveConnect.
126 * @param type -- Return type
127 * @param obj -- Java object.
128 * @param fieldID -- field id
129 * @param result -- return field value
130 * @param ctx -- security context
132 NS_IMETHOD
GetField(/*[in]*/ jni_type type
,
133 /*[in]*/ jobject obj
,
134 /*[in]*/ jfieldID fieldID
,
135 /*[out]*/ jvalue
* result
,
136 /*[in]*/ nsISecurityContext
* ctx
= NULL
) = 0;
139 * Set a field on Java object in LiveConnect.
141 * @param type -- Return type
142 * @param obj -- Java object.
143 * @param fieldID -- field id
144 * @param val -- field value to set
145 * @param ctx -- security context
147 NS_IMETHOD
SetField(/*[in]*/ jni_type type
,
148 /*[in]*/ jobject obj
,
149 /*[in]*/ jfieldID fieldID
,
151 /*[in]*/ nsISecurityContext
* ctx
= NULL
) = 0;
154 * Invoke static method on Java object in LiveConnect.
156 * @param type -- Return type
157 * @param clazz -- Class object.
158 * @param methodID -- method id
159 * @param args -- arguments for invoking the constructor.
160 * @param result -- return result of invocation.
161 * @param ctx -- security context
163 NS_IMETHOD
CallStaticMethod(/*[in]*/ jni_type type
,
164 /*[in]*/ jclass clazz
,
165 /*[in]*/ jmethodID methodID
,
166 /*[in]*/ jvalue
*args
,
167 /*[out]*/ jvalue
* result
,
168 /*[in]*/ nsISecurityContext
* ctx
= NULL
) = 0;
171 * Get a static field on Java object in LiveConnect.
173 * @param type -- Return type
174 * @param clazz -- Class object.
175 * @param fieldID -- field id
176 * @param result -- return field value
177 * @param ctx -- security context
179 NS_IMETHOD
GetStaticField(/*[in]*/ jni_type type
,
180 /*[in]*/ jclass clazz
,
181 /*[in]*/ jfieldID fieldID
,
182 /*[out]*/ jvalue
* result
,
183 /*[in]*/ nsISecurityContext
* ctx
= NULL
) = 0;
187 * Set a static field on Java object in LiveConnect.
189 * @param type -- Return type
190 * @param clazz -- Class object.
191 * @param fieldID -- field id
192 * @param val -- field value to set
193 * @param ctx -- security context
195 NS_IMETHOD
SetStaticField(/*[in]*/ jni_type type
,
196 /*[in]*/ jclass clazz
,
197 /*[in]*/ jfieldID fieldID
,
199 /*[in]*/ nsISecurityContext
* ctx
= NULL
) = 0;
202 NS_IMETHOD
GetVersion(/*[out]*/ jint
* version
) = 0;
204 NS_IMETHOD
DefineClass(/*[in]*/ const char* name
,
205 /*[in]*/ jobject loader
,
206 /*[in]*/ const jbyte
*buf
,
208 /*[out]*/ jclass
* clazz
) = 0;
210 NS_IMETHOD
FindClass(/*[in]*/ const char* name
,
211 /*[out]*/ jclass
* clazz
) = 0;
213 NS_IMETHOD
GetSuperclass(/*[in]*/ jclass sub
,
214 /*[out]*/ jclass
* super
) = 0;
216 NS_IMETHOD
IsAssignableFrom(/*[in]*/ jclass sub
,
217 /*[in]*/ jclass super
,
218 /*[out]*/ jboolean
* result
) = 0;
220 NS_IMETHOD
Throw(/*[in]*/ jthrowable obj
,
221 /*[out]*/ jint
* result
) = 0;
223 NS_IMETHOD
ThrowNew(/*[in]*/ jclass clazz
,
224 /*[in]*/ const char *msg
,
225 /*[out]*/ jint
* result
) = 0;
227 NS_IMETHOD
ExceptionOccurred(/*[out]*/ jthrowable
* result
) = 0;
229 NS_IMETHOD
ExceptionDescribe(void) = 0;
231 NS_IMETHOD
ExceptionClear(void) = 0;
233 NS_IMETHOD
FatalError(/*[in]*/ const char* msg
) = 0;
235 NS_IMETHOD
NewGlobalRef(/*[in]*/ jobject lobj
,
236 /*[out]*/ jobject
* result
) = 0;
238 NS_IMETHOD
DeleteGlobalRef(/*[in]*/ jobject gref
) = 0;
240 NS_IMETHOD
DeleteLocalRef(/*[in]*/ jobject obj
) = 0;
242 NS_IMETHOD
IsSameObject(/*[in]*/ jobject obj1
,
243 /*[in]*/ jobject obj2
,
244 /*[out]*/ jboolean
* result
) = 0;
246 NS_IMETHOD
AllocObject(/*[in]*/ jclass clazz
,
247 /*[out]*/ jobject
* result
) = 0;
249 NS_IMETHOD
GetObjectClass(/*[in]*/ jobject obj
,
250 /*[out]*/ jclass
* result
) = 0;
252 NS_IMETHOD
IsInstanceOf(/*[in]*/ jobject obj
,
253 /*[in]*/ jclass clazz
,
254 /*[out]*/ jboolean
* result
) = 0;
256 NS_IMETHOD
GetMethodID(/*[in]*/ jclass clazz
,
257 /*[in]*/ const char* name
,
258 /*[in]*/ const char* sig
,
259 /*[out]*/ jmethodID
* id
) = 0;
261 NS_IMETHOD
GetFieldID(/*[in]*/ jclass clazz
,
262 /*[in]*/ const char* name
,
263 /*[in]*/ const char* sig
,
264 /*[out]*/ jfieldID
* id
) = 0;
266 NS_IMETHOD
GetStaticMethodID(/*[in]*/ jclass clazz
,
267 /*[in]*/ const char* name
,
268 /*[in]*/ const char* sig
,
269 /*[out]*/ jmethodID
* id
) = 0;
271 NS_IMETHOD
GetStaticFieldID(/*[in]*/ jclass clazz
,
272 /*[in]*/ const char* name
,
273 /*[in]*/ const char* sig
,
274 /*[out]*/ jfieldID
* id
) = 0;
276 NS_IMETHOD
NewString(/*[in]*/ const jchar
* unicode
,
278 /*[out]*/ jstring
* result
) = 0;
280 NS_IMETHOD
GetStringLength(/*[in]*/ jstring str
,
281 /*[out]*/ jsize
* result
) = 0;
283 NS_IMETHOD
GetStringChars(/*[in]*/ jstring str
,
284 /*[in]*/ jboolean
*isCopy
,
285 /*[out]*/ const jchar
** result
) = 0;
287 NS_IMETHOD
ReleaseStringChars(/*[in]*/ jstring str
,
288 /*[in]*/ const jchar
*chars
) = 0;
290 NS_IMETHOD
NewStringUTF(/*[in]*/ const char *utf
,
291 /*[out]*/ jstring
* result
) = 0;
293 NS_IMETHOD
GetStringUTFLength(/*[in]*/ jstring str
,
294 /*[out]*/ jsize
* result
) = 0;
296 NS_IMETHOD
GetStringUTFChars(/*[in]*/ jstring str
,
297 /*[in]*/ jboolean
*isCopy
,
298 /*[out]*/ const char** result
) = 0;
300 NS_IMETHOD
ReleaseStringUTFChars(/*[in]*/ jstring str
,
301 /*[in]*/ const char *chars
) = 0;
303 NS_IMETHOD
GetArrayLength(/*[in]*/ jarray array
,
304 /*[out]*/ jsize
* result
) = 0;
306 NS_IMETHOD
NewObjectArray(/*[in]*/ jsize len
,
307 /*[in]*/ jclass clazz
,
308 /*[in]*/ jobject init
,
309 /*[out]*/ jobjectArray
* result
) = 0;
311 NS_IMETHOD
GetObjectArrayElement(/*[in]*/ jobjectArray array
,
312 /*[in]*/ jsize index
,
313 /*[out]*/ jobject
* result
) = 0;
315 NS_IMETHOD
SetObjectArrayElement(/*[in]*/ jobjectArray array
,
316 /*[in]*/ jsize index
,
317 /*[in]*/ jobject val
) = 0;
319 NS_IMETHOD
NewArray(/*[in]*/ jni_type element_type
,
321 /*[out]*/ jarray
* result
) = 0;
323 NS_IMETHOD
GetArrayElements(/*[in]*/ jni_type type
,
324 /*[in]*/ jarray array
,
325 /*[in]*/ jboolean
*isCopy
,
326 /*[out]*/ void* result
) = 0;
328 NS_IMETHOD
ReleaseArrayElements(/*[in]*/ jni_type type
,
329 /*[in]*/ jarray array
,
330 /*[in]*/ void *elems
,
331 /*[in]*/ jint mode
) = 0;
333 NS_IMETHOD
GetArrayRegion(/*[in]*/ jni_type type
,
334 /*[in]*/ jarray array
,
335 /*[in]*/ jsize start
,
337 /*[out]*/ void* buf
) = 0;
339 NS_IMETHOD
SetArrayRegion(/*[in]*/ jni_type type
,
340 /*[in]*/ jarray array
,
341 /*[in]*/ jsize start
,
343 /*[in]*/ void* buf
) = 0;
345 NS_IMETHOD
RegisterNatives(/*[in]*/ jclass clazz
,
346 /*[in]*/ const JNINativeMethod
*methods
,
347 /*[in]*/ jint nMethods
,
348 /*[out]*/ jint
* result
) = 0;
350 NS_IMETHOD
UnregisterNatives(/*[in]*/ jclass clazz
,
351 /*[out]*/ jint
* result
) = 0;
353 NS_IMETHOD
MonitorEnter(/*[in]*/ jobject obj
,
354 /*[out]*/ jint
* result
) = 0;
356 NS_IMETHOD
MonitorExit(/*[in]*/ jobject obj
,
357 /*[out]*/ jint
* result
) = 0;
359 NS_IMETHOD
GetJavaVM(/*[in]*/ JavaVM
**vm
,
360 /*[out]*/ jint
* result
) = 0;
363 NS_DEFINE_STATIC_IID_ACCESSOR(nsISecureEnv
, NS_ISECUREENV_IID
)
365 #endif // nsISecureEnv_h___