Back to index

lightning-sunbird  0.9+nobinonly
nsISecureJNI2.h
Go to the documentation of this file.
00001 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
00002 /* ***** BEGIN LICENSE BLOCK *****
00003  * Version: MPL 1.1/GPL 2.0/LGPL 2.1
00004  *
00005  * The contents of this file are subject to the Mozilla Public License Version
00006  * 1.1 (the "License"); you may not use this file except in compliance with
00007  * the License. You may obtain a copy of the License at
00008  * http://www.mozilla.org/MPL/
00009  *
00010  * Software distributed under the License is distributed on an "AS IS" basis,
00011  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
00012  * for the specific language governing rights and limitations under the
00013  * License.
00014  *
00015  * The Original Code is mozilla.org code.
00016  *
00017  * The Initial Developer of the Original Code is
00018  * Netscape Communications Corporation.
00019  * Portions created by the Initial Developer are Copyright (C) 1998
00020  * the Initial Developer. All Rights Reserved.
00021  *
00022  * Contributor(s):
00023  *
00024  * Alternatively, the contents of this file may be used under the terms of
00025  * either the GNU General Public License Version 2 or later (the "GPL"), or
00026  * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
00027  * in which case the provisions of the GPL or the LGPL are applicable instead
00028  * of those above. If you wish to allow use of your version of this file only
00029  * under the terms of either the GPL or the LGPL, and not to allow others to
00030  * use your version of this file under the terms of the MPL, indicate your
00031  * decision by deleting the provisions above and replace them with the notice
00032  * and other provisions required by the GPL or the LGPL. If you do not delete
00033  * the provisions above, a recipient may use your version of this file under
00034  * the terms of any one of the MPL, the GPL or the LGPL.
00035  *
00036  * ***** END LICENSE BLOCK ***** */
00037 
00038 #ifndef nsISecureJNI2_h___
00039 #define nsISecureJNI2_h___
00040 
00041 #include "nsISupports.h"
00042 #include "nsIFactory.h"
00043 #include "nsISecurityContext.h"
00044 #include "jni.h"
00045 
00046 enum jni_type 
00047 {
00048     jobject_type = 0,
00049     jboolean_type,
00050     jbyte_type,
00051     jchar_type,
00052     jshort_type,
00053     jint_type,
00054     jlong_type,
00055     jfloat_type,
00056     jdouble_type,
00057     jvoid_type
00058 };
00059 
00060 class nsISecureJNI2 : public nsISupports {
00061 public:
00062 
00072     NS_IMETHOD NewObject(/*[in]*/  jclass clazz, 
00073                          /*[in]*/  jmethodID methodID,
00074                          /*[in]*/  jvalue *args, 
00075                          /*[out]*/ jobject* result,
00076                          /*[in]*/  nsISecurityContext* ctx = NULL) = 0;
00077    
00088     NS_IMETHOD CallMethod(/*[in]*/  jni_type type,
00089                           /*[in]*/  jobject obj, 
00090                           /*[in]*/  jmethodID methodID,
00091                           /*[in]*/  jvalue *args, 
00092                           /*[out]*/ jvalue* result,
00093                           /*[in]*/  nsISecurityContext* ctx = NULL) = 0;
00094 
00106     NS_IMETHOD CallNonvirtualMethod(/*[in]*/  jni_type type,
00107                                     /*[in]*/  jobject obj, 
00108                                     /*[in]*/  jclass clazz,
00109                                     /*[in]*/  jmethodID methodID,
00110                                     /*[in]*/  jvalue *args, 
00111                                     /*[out]*/ jvalue* result,
00112                                     /*[in]*/  nsISecurityContext* ctx = NULL) = 0;
00113 
00123     NS_IMETHOD GetField(/*[in]*/  jni_type type,
00124                         /*[in]*/  jobject obj, 
00125                         /*[in]*/  jfieldID fieldID,
00126                         /*[out]*/ jvalue* result,
00127                         /*[in]*/  nsISecurityContext* ctx = NULL) = 0;
00128 
00138     NS_IMETHOD SetField(/*[in]*/ jni_type type,
00139                         /*[in]*/ jobject obj, 
00140                         /*[in]*/ jfieldID fieldID,
00141                         /*[in]*/ jvalue val,
00142                         /*[in]*/ nsISecurityContext* ctx = NULL) = 0;
00143 
00154     NS_IMETHOD CallStaticMethod(/*[in]*/  jni_type type,
00155                                 /*[in]*/  jclass clazz,
00156                                 /*[in]*/  jmethodID methodID,
00157                                 /*[in]*/  jvalue *args, 
00158                                 /*[out]*/ jvalue* result,
00159                                 /*[in]*/  nsISecurityContext* ctx = NULL) = 0;
00160 
00170     NS_IMETHOD GetStaticField(/*[in]*/  jni_type type,
00171                               /*[in]*/  jclass clazz, 
00172                               /*[in]*/  jfieldID fieldID, 
00173                               /*[out]*/ jvalue* result,
00174                               /*[in]*/  nsISecurityContext* ctx = NULL) = 0;
00175 
00176 
00186     NS_IMETHOD SetStaticField(/*[in]*/ jni_type type,
00187                               /*[in]*/ jclass clazz, 
00188                               /*[in]*/ jfieldID fieldID,
00189                               /*[in]*/ jvalue val,
00190                               /*[in]*/ nsISecurityContext* ctx = NULL) = 0;
00191 
00192 
00193     NS_IMETHOD GetVersion(/*[out]*/ jint* version) = 0;
00194 
00195     NS_IMETHOD DefineClass(/*[in]*/  const char* name,
00196                            /*[in]*/  jobject loader,
00197                            /*[in]*/  const jbyte *buf,
00198                            /*[in]*/  jsize len,
00199                            /*[out]*/ jclass* clazz) = 0;
00200 
00201     NS_IMETHOD FindClass(/*[in]*/  const char* name, 
00202                          /*[out]*/ jclass* clazz) = 0;
00203 
00204     NS_IMETHOD GetSuperclass(/*[in]*/  jclass sub,
00205                              /*[out]*/ jclass* super) = 0;
00206 
00207     NS_IMETHOD IsAssignableFrom(/*[in]*/  jclass sub,
00208                                 /*[in]*/  jclass super,
00209                                 /*[out]*/ jboolean* result) = 0;
00210 
00211     NS_IMETHOD Throw(/*[in]*/  jthrowable obj,
00212                      /*[out]*/ jint* result) = 0;
00213 
00214     NS_IMETHOD ThrowNew(/*[in]*/  jclass clazz,
00215                         /*[in]*/  const char *msg,
00216                         /*[out]*/ jint* result) = 0;
00217 
00218     NS_IMETHOD ExceptionOccurred(/*[out]*/ jthrowable* result) = 0;
00219 
00220     NS_IMETHOD ExceptionDescribe(void) = 0;
00221 
00222     NS_IMETHOD ExceptionClear(void) = 0;
00223 
00224     NS_IMETHOD FatalError(/*[in]*/ const char* msg) = 0;
00225 
00226     NS_IMETHOD NewGlobalRef(/*[in]*/  jobject lobj, 
00227                             /*[out]*/ jobject* result) = 0;
00228 
00229     NS_IMETHOD DeleteGlobalRef(/*[in]*/ jobject gref) = 0;
00230 
00231     NS_IMETHOD DeleteLocalRef(/*[in]*/ jobject obj) = 0;
00232 
00233     NS_IMETHOD IsSameObject(/*[in]*/  jobject obj1,
00234                             /*[in]*/  jobject obj2,
00235                             /*[out]*/ jboolean* result) = 0;
00236 
00237     NS_IMETHOD AllocObject(/*[in]*/  jclass clazz,
00238                            /*[out]*/ jobject* result) = 0;
00239 
00240     NS_IMETHOD GetObjectClass(/*[in]*/  jobject obj,
00241                               /*[out]*/ jclass* result) = 0;
00242 
00243     NS_IMETHOD IsInstanceOf(/*[in]*/  jobject obj,
00244                             /*[in]*/  jclass clazz,
00245                             /*[out]*/ jboolean* result) = 0;
00246 
00247     NS_IMETHOD GetMethodID(/*[in]*/  jclass clazz, 
00248                            /*[in]*/  const char* name,
00249                            /*[in]*/  const char* sig,
00250                            /*[out]*/ jmethodID* id) = 0;
00251 
00252     NS_IMETHOD GetFieldID(/*[in]*/  jclass clazz, 
00253                           /*[in]*/  const char* name,
00254                           /*[in]*/  const char* sig,
00255                           /*[out]*/ jfieldID* id) = 0;
00256 
00257     NS_IMETHOD GetStaticMethodID(/*[in]*/  jclass clazz, 
00258                                  /*[in]*/  const char* name,
00259                                  /*[in]*/  const char* sig,
00260                                  /*[out]*/ jmethodID* id) = 0;
00261 
00262     NS_IMETHOD GetStaticFieldID(/*[in]*/  jclass clazz, 
00263                                 /*[in]*/  const char* name,
00264                                 /*[in]*/  const char* sig,
00265                                 /*[out]*/ jfieldID* id) = 0;
00266 
00267     NS_IMETHOD NewString(/*[in]*/  const jchar* unicode,
00268                          /*[in]*/  jsize len,
00269                          /*[out]*/ jstring* result) = 0;
00270 
00271     NS_IMETHOD GetStringLength(/*[in]*/  jstring str,
00272                                /*[out]*/ jsize* result) = 0;
00273     
00274     NS_IMETHOD GetStringChars(/*[in]*/  jstring str,
00275                               /*[in]*/  jboolean *isCopy,
00276                               /*[out]*/ const jchar** result) = 0;
00277 
00278     NS_IMETHOD ReleaseStringChars(/*[in]*/  jstring str,
00279                                   /*[in]*/  const jchar *chars) = 0;
00280 
00281     NS_IMETHOD NewStringUTF(/*[in]*/  const char *utf,
00282                             /*[out]*/ jstring* result) = 0;
00283 
00284     NS_IMETHOD GetStringUTFLength(/*[in]*/  jstring str,
00285                                   /*[out]*/ jsize* result) = 0;
00286     
00287     NS_IMETHOD GetStringUTFChars(/*[in]*/  jstring str,
00288                                  /*[in]*/  jboolean *isCopy,
00289                                  /*[out]*/ const char** result) = 0;
00290 
00291     NS_IMETHOD ReleaseStringUTFChars(/*[in]*/  jstring str,
00292                                      /*[in]*/  const char *chars) = 0;
00293 
00294     NS_IMETHOD GetArrayLength(/*[in]*/  jarray array,
00295                               /*[out]*/ jsize* result) = 0;
00296 
00297     NS_IMETHOD NewObjectArray(/*[in]*/  jsize len,
00298                                    /*[in]*/  jclass clazz,
00299                         /*[in]*/  jobject init,
00300                         /*[out]*/ jobjectArray* result) = 0;
00301 
00302     NS_IMETHOD GetObjectArrayElement(/*[in]*/  jobjectArray array,
00303                                      /*[in]*/  jsize index,
00304                                      /*[out]*/ jobject* result) = 0;
00305 
00306     NS_IMETHOD SetObjectArrayElement(/*[in]*/  jobjectArray array,
00307                                      /*[in]*/  jsize index,
00308                                      /*[in]*/  jobject val) = 0;
00309 
00310     NS_IMETHOD NewArray(/*[in]*/ jni_type element_type,
00311                         /*[in]*/  jsize len,
00312                         /*[out]*/ jarray* result) = 0;
00313 
00314     NS_IMETHOD GetArrayElements(/*[in]*/  jni_type type,
00315                                 /*[in]*/  jarray array,
00316                                 /*[in]*/  jboolean *isCopy,
00317                                 /*[out]*/ void* result) = 0;
00318 
00319     NS_IMETHOD ReleaseArrayElements(/*[in]*/ jni_type type,
00320                                     /*[in]*/ jarray array,
00321                                     /*[in]*/ void *elems,
00322                                     /*[in]*/ jint mode) = 0;
00323 
00324     NS_IMETHOD GetArrayRegion(/*[in]*/  jni_type type,
00325                               /*[in]*/  jarray array,
00326                               /*[in]*/  jsize start,
00327                               /*[in]*/  jsize len,
00328                               /*[out]*/ void* buf) = 0;
00329 
00330     NS_IMETHOD SetArrayRegion(/*[in]*/  jni_type type,
00331                               /*[in]*/  jarray array,
00332                               /*[in]*/  jsize start,
00333                               /*[in]*/  jsize len,
00334                               /*[in]*/  void* buf) = 0;
00335 
00336     NS_IMETHOD RegisterNatives(/*[in]*/  jclass clazz,
00337                                /*[in]*/  const JNINativeMethod *methods,
00338                                /*[in]*/  jint nMethods,
00339                                /*[out]*/ jint* result) = 0;
00340 
00341     NS_IMETHOD UnregisterNatives(/*[in]*/  jclass clazz,
00342                                  /*[out]*/ jint* result) = 0;
00343 
00344     NS_IMETHOD MonitorEnter(/*[in]*/  jobject obj,
00345                             /*[out]*/ jint* result) = 0;
00346 
00347     NS_IMETHOD MonitorExit(/*[in]*/  jobject obj,
00348                            /*[out]*/ jint* result) = 0;
00349 
00350     NS_IMETHOD GetJavaVM(/*[in]*/  JavaVM **vm,
00351                          /*[out]*/ jint* result) = 0;
00352 };
00353 
00354 #define NS_ISECUREJNI2_IID                              \
00355 {   /* ca9148d0-598a-11d2-a1d4-00805f8f694d */          \
00356     0xca9148d0,                                         \
00357     0x598a,                                             \
00358     0x11d2,                                             \
00359     {0xa1, 0xd4, 0x00, 0x80, 0x5f, 0x8f, 0x69, 0x4d }   \
00360 }
00361 
00362 #endif // nsISecureJNI2_h___