Methods of PlugletTagInfo and PlugletTagInfo2 doesn't allow access to pluglet parameters,
PlugletTagInfo2 getAttribute doesn't work properly.

Reviewed by idk@eng.sun.com
This commit is contained in:
laa%sparc.spb.su 2000-01-28 18:11:27 +00:00
Родитель 46362c1976
Коммит 1121925eee
4 изменённых файлов: 158 добавлений и 11 удалений

Просмотреть файл

@ -28,6 +28,8 @@ import java.util.*;
public interface PlugletTagInfo2 extends PlugletTagInfo {
public Properties getAttributes();
public String getAttribute(String name);
public Properties getParameters();
public String getParameter(String name);
/** Gets the HTML tag type associated with creation of the
* <code>Pluglet</code> instance. Possible types are <code>EMBED</code>,
* <code>APPLET</code>, and <code>OBJECT</code>.<p>

Просмотреть файл

@ -27,8 +27,32 @@ public class PlugletTagInfo2Impl implements PlugletTagInfo2 {
peer = _peer;
nativeInitialize();
}
public native Properties getAttributes();
private native String[][] getAttributesArray();
public Properties getAttributes() {
Properties result = new Properties();
String[][] attrs = getAttributesArray();
if (attrs == null) {
return null;
}
for(int i=0; i < attrs[0].length; i++) {
result.setProperty(attrs[0][i], attrs[1][i]);
}
return result;
}
public native String getAttribute(String name);
private native String[][] getParametersArray();
public Properties getParameters() {
Properties result = new Properties();
String[][] params = getParametersArray();
if (params == null) {
return null;
}
for(int i=0; i < params[1].length; i++) {
result.setProperty(params[0][i], params[1][i]);
}
return result;
}
public native String getParameter(String name);
/* Get the type of the HTML tag that was used ot instantiate this
* pluglet. Currently supported tags are EMBED, APPLET and OBJECT.
*/

Просмотреть файл

@ -25,15 +25,48 @@
static jfieldID peerFID = NULL;
/*
* Class: org_mozilla_pluglet_mozilla_PlugletTagInfo2Impl
* Method: getAttributes
* Signature: ()Ljava/util/Properties;
* Method: getAttributesArray
* Signature: ()[[Ljava/lang/String;
*/
JNIEXPORT jobject JNICALL Java_org_mozilla_pluglet_mozilla_PlugletTagInfo2Impl_getAttributes
(JNIEnv *, jobject) {
JNIEXPORT jobjectArray JNICALL Java_org_mozilla_pluglet_mozilla_PlugletTagInfo2Impl_getAttributesArray
(JNIEnv *env, jobject jthis) {
jobjectArray jnames;
jobjectArray jvalues;
jobjectArray result;
char*const* names;
char*const* values;
PRUint16 nAttr;
PR_LOG(PlugletLog::log, PR_LOG_DEBUG,
("PlugletTagInfo2Impl.getAttributes: stub\n"));
//nb Java_org_mozilla_pluglet_mozilla_PlugletTagInfo2Impl_getAttributes
return NULL;
("PlugletTagInfo2Impl.getAttributesArray\n"));
nsIPluginTagInfo2 * info = (nsIPluginTagInfo2*)env->GetLongField(jthis, peerFID);
if (!info) {
return NULL;
}
if (NS_FAILED(info->GetAttributes(nAttr, names, values))) {
return NULL;
}
jclass strClass = env->FindClass("java/lang/String");
jclass strArrayClass = env->FindClass("[Ljava/lang/String;");
if (!strClass || !strArrayClass) {
return NULL;
}
result = env->NewObjectArray(2, strArrayClass, NULL);
jnames = env->NewObjectArray(nAttr, strClass, NULL);
jvalues = env->NewObjectArray(nAttr, strClass, NULL);
int i;
for (i=0; i < nAttr; i++) {
env->SetObjectArrayElement(jnames, i, env->NewStringUTF(names[i]));
env->SetObjectArrayElement(jvalues, i, env->NewStringUTF(values[i]));
}
env->SetObjectArrayElement(result, 0, jnames);
env->SetObjectArrayElement(result, 1, jvalues);
env->DeleteLocalRef(jnames);
env->DeleteLocalRef(jvalues);
return result;
}
/*
@ -54,6 +87,78 @@ JNIEXPORT jstring JNICALL Java_org_mozilla_pluglet_mozilla_PlugletTagInfo2Impl_g
return NULL;
}
const char * result = NULL;
if (NS_FAILED(info->GetAttribute(name,&result))) {
env->ReleaseStringUTFChars(_name,name);
return NULL;
}
env->ReleaseStringUTFChars(_name,name);
return env->NewStringUTF(result);
}
/*
* Class: org_mozilla_pluglet_mozilla_PlugletTagInfo2Impl
* Method: getParametersArray
* Signature: ()[[Ljava/lang/String;
*/
JNIEXPORT jobjectArray JNICALL Java_org_mozilla_pluglet_mozilla_PlugletTagInfo2Impl_getParametersArray
(JNIEnv *env, jobject jthis) {
jobjectArray jnames;
jobjectArray jvalues;
jobjectArray result;
char*const* names;
char*const* values;
PRUint16 nParam;
PR_LOG(PlugletLog::log, PR_LOG_DEBUG,
("PlugletTagInfo2Impl.getParameters\n"));
nsIPluginTagInfo2 * info = (nsIPluginTagInfo2*)env->GetLongField(jthis, peerFID);
if (!info) {
return NULL;
}
if (NS_FAILED(info->GetParameters(nParam, names, values))) {
return NULL;
}
jclass strClass = env->FindClass("java/lang/String");
jclass strArrayClass = env->FindClass("[Ljava/lang/String;");
if (!strClass || !strArrayClass) {
return NULL;
}
result = env->NewObjectArray(2, strArrayClass, NULL);
jnames = env->NewObjectArray(nParam, strClass, NULL);
jvalues = env->NewObjectArray(nParam, strClass, NULL);
int i;
for (i=0; i < nParam; i++) {
env->SetObjectArrayElement(jnames, i, env->NewStringUTF(names[i]));
env->SetObjectArrayElement(jvalues, i, env->NewStringUTF(values[i]));
}
env->SetObjectArrayElement(result, 0, jnames);
env->SetObjectArrayElement(result, 1, jvalues);
env->DeleteLocalRef(jnames);
env->DeleteLocalRef(jvalues);
return result;
}
/*
* Class: org_mozilla_pluglet_mozilla_PlugletTagInfo2Impl
* Method: getParameter
* Signature: (Ljava/lang/String;)Ljava/lang/String;
*/
JNIEXPORT jstring JNICALL Java_org_mozilla_pluglet_mozilla_PlugletTagInfo2Impl_getParameter
(JNIEnv *env, jobject jthis, jstring _name) {
PR_LOG(PlugletLog::log, PR_LOG_DEBUG,
("PlugletTagInfo2Impl.getParameter: name = %s\n", _name));
if (!_name) {
return NULL;
}
nsIPluginTagInfo2 * info = (nsIPluginTagInfo2*)env->GetLongField(jthis, peerFID);
const char * name = NULL;
if (!(name = env->GetStringUTFChars(_name,NULL))) {
return NULL;
}
const char * result = NULL;
if (NS_FAILED(info->GetParameter(name,&result))) {
env->ReleaseStringUTFChars(_name,name);
return NULL;

Просмотреть файл

@ -29,10 +29,10 @@ extern "C" {
#endif
/*
* Class: org_mozilla_pluglet_mozilla_PlugletTagInfo2Impl
* Method: getAttributes
* Signature: ()Ljava/util/Properties;
* Method: getAttributesArray
* Signature: ()[[Ljava/lang/String;
*/
JNIEXPORT jobject JNICALL Java_org_mozilla_pluglet_mozilla_PlugletTagInfo2Impl_getAttributes
JNIEXPORT jobjectArray JNICALL Java_org_mozilla_pluglet_mozilla_PlugletTagInfo2Impl_getAttributesArray
(JNIEnv *, jobject);
/*
@ -43,6 +43,22 @@ JNIEXPORT jobject JNICALL Java_org_mozilla_pluglet_mozilla_PlugletTagInfo2Impl_g
JNIEXPORT jstring JNICALL Java_org_mozilla_pluglet_mozilla_PlugletTagInfo2Impl_getAttribute
(JNIEnv *, jobject, jstring);
/*
* Class: org_mozilla_pluglet_mozilla_PlugletTagInfo2Impl
* Method: getParametersArray
* Signature: ()[[Ljava/lang/String;
*/
JNIEXPORT jobjectArray JNICALL Java_org_mozilla_pluglet_mozilla_PlugletTagInfo2Impl_getParametersArray
(JNIEnv *, jobject);
/*
* Class: org_mozilla_pluglet_mozilla_PlugletTagInfo2Impl
* Method: getParameter
* Signature: (Ljava/lang/String;)Ljava/lang/String;
*/
JNIEXPORT jstring JNICALL Java_org_mozilla_pluglet_mozilla_PlugletTagInfo2Impl_getParameter
(JNIEnv *, jobject, jstring);
/*
* Class: org_mozilla_pluglet_mozilla_PlugletTagInfo2Impl
* Method: getTagType