bug 18180
Names changed Pluglet->PlugletFactory, *PlugletInstance*->*Pluglet* git-svn-id: svn://10.0.0.236/trunk@52992 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
68
mozilla/java/plugins/src/List.cpp
Normal file
68
mozilla/java/plugins/src/List.cpp
Normal file
@@ -0,0 +1,68 @@
|
||||
/*
|
||||
* The contents of this file are subject to the Mozilla Public License
|
||||
* Version 1.0 (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 Initial Developer of the Original Code is Sun Microsystems,
|
||||
* Inc. Portions created by Sun are Copyright (C) 1999 Sun Microsystems,
|
||||
* Inc. All Rights Reserved.
|
||||
*/
|
||||
#include"List.h"
|
||||
|
||||
List::List() {
|
||||
head = tail = NULL;
|
||||
}
|
||||
|
||||
List::~List() {
|
||||
ListNode *tmp;
|
||||
for(ListNode * current=head;!current;tmp = current,current = current->next, delete tmp)
|
||||
;
|
||||
}
|
||||
|
||||
List::ListNode::ListNode(void *v,List::ListNode *n) {
|
||||
value = v; next = n;
|
||||
}
|
||||
|
||||
void List::Add(void *v) {
|
||||
if (!v) {
|
||||
return;
|
||||
}
|
||||
if (!tail) {
|
||||
head = tail = new ListNode(v);
|
||||
} else {
|
||||
tail->next = new ListNode(v);
|
||||
if (tail->next) {
|
||||
tail = tail->next;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ListIterator * List::GetIterator(void) {
|
||||
return new ListIterator(this);
|
||||
}
|
||||
|
||||
ListIterator::ListIterator(List *list) {
|
||||
current = list->head;
|
||||
}
|
||||
void * ListIterator::Get(void) {
|
||||
void * result = NULL;
|
||||
if (current) {
|
||||
result = current->value;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
void * ListIterator::Next(void) {
|
||||
void * result = NULL;
|
||||
if (current) {
|
||||
current = current->next;
|
||||
result = Get();
|
||||
}
|
||||
return result;
|
||||
}
|
||||
46
mozilla/java/plugins/src/List.h
Normal file
46
mozilla/java/plugins/src/List.h
Normal file
@@ -0,0 +1,46 @@
|
||||
/*
|
||||
* The contents of this file are subject to the Mozilla Public License
|
||||
* Version 1.0 (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 Initial Developer of the Original Code is Sun Microsystems,
|
||||
* Inc. Portions created by Sun are Copyright (C) 1999 Sun Microsystems,
|
||||
* Inc. All Rights Reserved.
|
||||
*/
|
||||
#ifndef __List_h__
|
||||
#define __List_h__
|
||||
#include <stdlib.h> //in order to have NULL definition
|
||||
class ListIterator;
|
||||
|
||||
class List {
|
||||
friend class ListIterator;
|
||||
public:
|
||||
List();
|
||||
~List();
|
||||
void Add(void *value);
|
||||
ListIterator * GetIterator(void);
|
||||
private:
|
||||
struct ListNode {
|
||||
ListNode(void *v,ListNode *n = NULL);
|
||||
void * value;
|
||||
ListNode * next;
|
||||
};
|
||||
ListNode * head;
|
||||
ListNode * tail;
|
||||
};
|
||||
class ListIterator {
|
||||
public:
|
||||
ListIterator(List *list);
|
||||
void * Get(void);
|
||||
void * Next(void);
|
||||
private:
|
||||
List::ListNode *current;
|
||||
};
|
||||
|
||||
#endif /* __List_h__ */
|
||||
@@ -1,4 +1,4 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
/*
|
||||
* 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
|
||||
@@ -20,161 +20,170 @@
|
||||
*/
|
||||
#include "Pluglet.h"
|
||||
#include "PlugletEngine.h"
|
||||
#include "PlugletLoader.h"
|
||||
#include "PlugletInstance.h"
|
||||
#include "string.h"
|
||||
#include "PlugletStreamListener.h"
|
||||
#include "PlugletPeer.h"
|
||||
#include "Registry.h"
|
||||
|
||||
jmethodID Pluglet::createPlugletInstanceMID = NULL;
|
||||
jmethodID Pluglet::initializeMID = NULL;
|
||||
jmethodID Pluglet::shutdownMID = NULL;
|
||||
jmethodID Pluglet::initializeMID = NULL;
|
||||
jmethodID Pluglet::startMID = NULL;
|
||||
jmethodID Pluglet::stopMID = NULL;
|
||||
jmethodID Pluglet::destroyMID = NULL;
|
||||
jmethodID Pluglet::newStreamMID = NULL;
|
||||
jmethodID Pluglet::setWindowMID = NULL;
|
||||
jmethodID Pluglet::printMID = NULL;
|
||||
|
||||
static NS_DEFINE_IID(kIPluginInstanceIID, NS_IPLUGININSTANCE_IID);
|
||||
|
||||
nsresult Pluglet::CreatePluginInstance(const char* aPluginMIMEType, void **aResult) {
|
||||
if(!aResult
|
||||
|| Initialize() != NS_OK) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
JNIEnv *env = PlugletEngine::GetJNIEnv();
|
||||
if(!env) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
jstring jstr = env->NewStringUTF(aPluginMIMEType);
|
||||
jobject obj = env->CallObjectMethod(jthis,createPlugletInstanceMID, jstr);
|
||||
if (!obj) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
if (env->ExceptionOccurred()) {
|
||||
env->ExceptionDescribe();
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
nsISupports * instance = new PlugletInstance(obj);
|
||||
NS_ADDREF(instance);
|
||||
*aResult = instance;
|
||||
NS_IMPL_ISUPPORTS(Pluglet, kIPluginInstanceIID);
|
||||
|
||||
Pluglet::Pluglet(jobject object) {
|
||||
NS_INIT_REFCNT();
|
||||
jthis = PlugletEngine::GetJNIEnv()->NewGlobalRef(object);
|
||||
//nb check for null
|
||||
peer = NULL;
|
||||
view = new PlugletView();
|
||||
Registry::SetPeer(jthis,(jlong)this);
|
||||
}
|
||||
|
||||
Pluglet::~Pluglet() {
|
||||
Registry::Remove(jthis);
|
||||
PlugletEngine::GetJNIEnv()->DeleteGlobalRef(jthis);
|
||||
NS_RELEASE(peer);
|
||||
}
|
||||
|
||||
NS_METHOD Pluglet::HandleEvent(nsPluginEvent* event, PRBool* handled) {
|
||||
//nb we do not need it under win32
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult Pluglet::Initialize(void) {
|
||||
NS_METHOD Pluglet::Initialize(nsIPluginInstancePeer* _peer) {
|
||||
JNIEnv *env = PlugletEngine::GetJNIEnv();
|
||||
if(!env) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
if (!initializeMID) {
|
||||
if (!printMID) {
|
||||
jclass clazz = env->FindClass("org/mozilla/pluglet/Pluglet");
|
||||
if(!clazz) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
createPlugletInstanceMID = env->GetMethodID(clazz,"createPlugletInstance","(Ljava/lang/String;)Lorg/mozilla/pluglet/PlugletInstance;");
|
||||
if (!createPlugletInstanceMID) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
shutdownMID = env->GetMethodID(clazz,"shutdown","()V");
|
||||
if (!shutdownMID) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
initializeMID = env->GetMethodID(clazz,"initialize","(Lorg/mozilla/pluglet/mozilla/PlugletManager;)V");
|
||||
if (!initializeMID) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
}
|
||||
if (!jthis) {
|
||||
jthis = PlugletLoader::GetPluglet(path);
|
||||
if (!jthis) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
env->CallVoidMethod(jthis,initializeMID,PlugletEngine::GetPlugletManager());
|
||||
if (env->ExceptionOccurred()) {
|
||||
env->ExceptionDescribe();
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
env->ExceptionDescribe();
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
initializeMID = env->GetMethodID(clazz,"initialize","(Lorg/mozilla/pluglet/mozilla/PlugletPeer;)V");
|
||||
if (env->ExceptionOccurred()) {
|
||||
env->ExceptionDescribe();
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
startMID = env->GetMethodID(clazz,"start","()V");
|
||||
if (env->ExceptionOccurred()) {
|
||||
env->ExceptionDescribe();
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
stopMID = env->GetMethodID(clazz,"stop","()V");
|
||||
if (env->ExceptionOccurred()) {
|
||||
env->ExceptionDescribe();
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
destroyMID = env->GetMethodID(clazz,"destroy","()V");
|
||||
if (env->ExceptionOccurred()) {
|
||||
env->ExceptionDescribe();
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
newStreamMID = env->GetMethodID(clazz,"newStream","()Lorg/mozilla/pluglet/PlugletStreamListener;");
|
||||
if (env->ExceptionOccurred()) {
|
||||
env->ExceptionDescribe();
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
setWindowMID = env->GetMethodID(clazz,"setWindow","(Ljava/awt/Frame;)V");
|
||||
if (env->ExceptionOccurred()) {
|
||||
env->ExceptionDescribe();
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
printMID = env->GetMethodID(clazz,"print","(Ljava/awt/print/PrinterJob;)V");
|
||||
if (env->ExceptionOccurred()) {
|
||||
env->ExceptionDescribe();
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
}
|
||||
peer = _peer;
|
||||
peer->AddRef();
|
||||
jobject obj = PlugletPeer::GetJObject(peer);
|
||||
if (!obj) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
env->CallVoidMethod(jthis,initializeMID,obj);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult Pluglet::Shutdown(void) {
|
||||
|
||||
if(!jthis) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
JNIEnv *env = PlugletEngine::GetJNIEnv();
|
||||
if(!env) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
env->CallVoidMethod(jthis,shutdownMID);
|
||||
NS_METHOD Pluglet::GetPeer(nsIPluginInstancePeer* *result) {
|
||||
peer->AddRef();
|
||||
*result = peer;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_METHOD Pluglet::Start(void) {
|
||||
JNIEnv * env = PlugletEngine::GetJNIEnv();
|
||||
env->CallVoidMethod(jthis,startMID);
|
||||
if (env->ExceptionOccurred()) {
|
||||
env->ExceptionDescribe();
|
||||
env->ExceptionDescribe();
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
NS_METHOD Pluglet::Stop(void) {
|
||||
JNIEnv * env = PlugletEngine::GetJNIEnv();
|
||||
env->CallVoidMethod(jthis,stopMID);
|
||||
if (env->ExceptionOccurred()) {
|
||||
env->ExceptionDescribe();
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
NS_METHOD Pluglet::Destroy(void) {
|
||||
JNIEnv * env = PlugletEngine::GetJNIEnv();
|
||||
env->CallVoidMethod(jthis,destroyMID);
|
||||
if (env->ExceptionOccurred()) {
|
||||
env->ExceptionDescribe();
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_METHOD Pluglet::NewStream(nsIPluginStreamListener** listener) {
|
||||
if(!listener) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
JNIEnv * env = PlugletEngine::GetJNIEnv();
|
||||
jobject obj = env->CallObjectMethod(jthis,newStreamMID);
|
||||
if (env->ExceptionOccurred()) {
|
||||
env->ExceptionDescribe();
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
if (obj) {
|
||||
*listener = new PlugletStreamListener(obj);
|
||||
(*listener)->AddRef();
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult Pluglet::GetMIMEDescription(const char* *result) {
|
||||
if(!result) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
*result = mimeDescription;
|
||||
return (*result) ? NS_OK : NS_ERROR_FAILURE;
|
||||
NS_METHOD Pluglet::GetValue(nsPluginInstanceVariable variable, void *value) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
Pluglet::Pluglet(const char *mimeDescription, const char *path) {
|
||||
jthis = NULL;
|
||||
this->path = new char[strlen(path)+1];
|
||||
strcpy(this->path,path);
|
||||
this->mimeDescription = new char[strlen(mimeDescription)+1];
|
||||
strcpy(this->mimeDescription,mimeDescription);
|
||||
|
||||
}
|
||||
|
||||
Pluglet::~Pluglet(void) {
|
||||
if (path != NULL) {
|
||||
delete[] path;
|
||||
}
|
||||
if (mimeDescription != NULL) {
|
||||
delete[] mimeDescription;
|
||||
}
|
||||
NS_METHOD Pluglet::SetWindow(nsPluginWindow* window) {
|
||||
JNIEnv *env = PlugletEngine::GetJNIEnv();
|
||||
if (env != NULL) {
|
||||
env->DeleteGlobalRef(jthis);
|
||||
if (view->SetWindow(window)) {
|
||||
env->CallVoidMethod(jthis,setWindowMID,view->GetJObject());
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
Pluglet * Pluglet::Load(const char * path) {
|
||||
char * mime = PlugletLoader::GetMIMEDescription(path);
|
||||
Pluglet * result = NULL;
|
||||
if (mime) {
|
||||
result = new Pluglet(mime,path);
|
||||
//delete[] mime; //nb we have a strange exception here
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/*
|
||||
1 if good
|
||||
0 if not good
|
||||
*/
|
||||
int Pluglet::Compare(const char *mimeType) {
|
||||
/* mimedDescription mimeTypes:extensions:description
|
||||
mimeTypes mimeType;mimeType;...
|
||||
extensions extension;extension;...
|
||||
*/
|
||||
if (!mimeType) {
|
||||
return 0;
|
||||
}
|
||||
char * terminator = strchr(mimeDescription,':'); // terminator have to be not equal to NULL;
|
||||
char *p1 = mimeDescription;
|
||||
char *p2 = strchr(p1,';');
|
||||
while ( p1 != NULL && p1 < terminator ) {
|
||||
size_t n = sizeof(char) * ( ( (p2 == NULL) ? terminator : p2) - p1 );
|
||||
if (PL_strncasecmp(p1,mimeType,n) == 0) {
|
||||
return 1;
|
||||
}
|
||||
p1 = p2 ;
|
||||
if (p2 != NULL) {
|
||||
p2 = strchr(++p2,';');
|
||||
p1++;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
NS_METHOD Pluglet::Print(nsPluginPrint* platformPrint) {
|
||||
//nb
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -22,26 +22,35 @@
|
||||
#define __Pluglet_h__
|
||||
#include "nsplugin.h"
|
||||
#include "jni.h"
|
||||
#include "PlugletView.h"
|
||||
|
||||
class Pluglet {
|
||||
class Pluglet : public nsIPluginInstance {
|
||||
public:
|
||||
nsresult CreatePluginInstance(const char* aPluginMIMEType, void **aResult);
|
||||
nsresult Initialize(void);
|
||||
nsresult Shutdown(void);
|
||||
nsresult GetMIMEDescription(const char* *result);
|
||||
/*****************************************/
|
||||
~Pluglet(void);
|
||||
int Compare(const char * mimeType);
|
||||
static Pluglet * Load(const char * path);
|
||||
NS_IMETHOD HandleEvent(nsPluginEvent* event, PRBool* handled);
|
||||
NS_IMETHOD Initialize(nsIPluginInstancePeer* peer);
|
||||
NS_IMETHOD GetPeer(nsIPluginInstancePeer* *result);
|
||||
NS_IMETHOD Start(void);
|
||||
NS_IMETHOD Stop(void);
|
||||
NS_IMETHOD Destroy(void);
|
||||
NS_IMETHOD NewStream(nsIPluginStreamListener** listener);
|
||||
NS_IMETHOD SetWindow(nsPluginWindow* window);
|
||||
NS_IMETHOD Print(nsPluginPrint* platformPrint);
|
||||
NS_IMETHOD GetValue(nsPluginInstanceVariable variable, void *value);
|
||||
NS_DECL_ISUPPORTS
|
||||
|
||||
Pluglet(jobject object);
|
||||
virtual ~Pluglet(void);
|
||||
private:
|
||||
jobject jthis;
|
||||
static jmethodID createPlugletInstanceMID;
|
||||
static jmethodID initializeMID;
|
||||
static jmethodID shutdownMID;
|
||||
/*****************************************/
|
||||
char *mimeDescription;
|
||||
char *path;
|
||||
Pluglet(const char *mimeDescription,const char * path);
|
||||
};
|
||||
|
||||
static jmethodID initializeMID;
|
||||
static jmethodID startMID;
|
||||
static jmethodID stopMID;
|
||||
static jmethodID destroyMID;
|
||||
static jmethodID newStreamMID;
|
||||
static jmethodID setWindowMID;
|
||||
static jmethodID printMID;
|
||||
static jmethodID getValueMID;
|
||||
nsIPluginInstancePeer *peer;
|
||||
PlugletView *view;
|
||||
};
|
||||
#endif /* __Pluglet_h__ */
|
||||
|
||||
@@ -70,14 +70,14 @@ NS_METHOD PlugletEngine::CreatePluginInstance(nsISupports *aOuter, REFNSIID aIID
|
||||
if (!aResult) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
Pluglet * pluglet = NULL;
|
||||
PlugletFactory * plugletFactory = NULL;
|
||||
nsresult res = NS_ERROR_NULL_POINTER;
|
||||
if ((res = dir->GetPluglet(aPluginMIMEType,&pluglet)) != NS_OK
|
||||
|| !pluglet) {
|
||||
if ((res = dir->GetPlugletFactory(aPluginMIMEType,&plugletFactory)) != NS_OK
|
||||
|| !plugletFactory) {
|
||||
return res;
|
||||
}
|
||||
//we do not delete pluglet because we do not allocate new memory in dir->GetPluglet()
|
||||
return pluglet->CreatePluginInstance(aPluginMIMEType,aResult);
|
||||
return plugletFactory->CreatePluginInstance(aPluginMIMEType,aResult);
|
||||
}
|
||||
|
||||
NS_METHOD PlugletEngine::GetMIMEDescription(const char* *result) {
|
||||
|
||||
181
mozilla/java/plugins/src/PlugletFactory.cpp
Normal file
181
mozilla/java/plugins/src/PlugletFactory.cpp
Normal file
@@ -0,0 +1,181 @@
|
||||
/*
|
||||
* 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 Sun Microsystems,
|
||||
* Inc. Portions created by Sun are
|
||||
* Copyright (C) 1999 Sun Microsystems, Inc. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*/
|
||||
#include "PlugletFactory.h"
|
||||
#include "PlugletEngine.h"
|
||||
#include "PlugletLoader.h"
|
||||
#include "Pluglet.h"
|
||||
#include "string.h"
|
||||
|
||||
jmethodID PlugletFactory::createPlugletMID = NULL;
|
||||
jmethodID PlugletFactory::initializeMID = NULL;
|
||||
jmethodID PlugletFactory::shutdownMID = NULL;
|
||||
|
||||
|
||||
nsresult PlugletFactory::CreatePluginInstance(const char* aPluginMIMEType, void **aResult) {
|
||||
if(!aResult
|
||||
|| Initialize() != NS_OK) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
JNIEnv *env = PlugletEngine::GetJNIEnv();
|
||||
if(!env) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
jstring jstr = env->NewStringUTF(aPluginMIMEType);
|
||||
jobject obj = env->CallObjectMethod(jthis,createPlugletMID, jstr);
|
||||
if (env->ExceptionOccurred()) {
|
||||
env->ExceptionDescribe();
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
nsISupports * instance = new Pluglet(obj);
|
||||
NS_ADDREF(instance);
|
||||
*aResult = instance;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult PlugletFactory::Initialize(void) {
|
||||
JNIEnv *env = PlugletEngine::GetJNIEnv();
|
||||
if(!env) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
if (!initializeMID) {
|
||||
jclass clazz = env->FindClass("org/mozilla/pluglet/PlugletFactory");
|
||||
if(!clazz) {
|
||||
env->ExceptionDescribe();
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
createPlugletMID = env->GetMethodID(clazz,"createPluglet","(Ljava/lang/String;)Lorg/mozilla/pluglet/Pluglet;");
|
||||
if (!createPlugletMID) {
|
||||
env->ExceptionDescribe();
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
shutdownMID = env->GetMethodID(clazz,"shutdown","()V");
|
||||
if (!shutdownMID) {
|
||||
env->ExceptionDescribe();
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
initializeMID = env->GetMethodID(clazz,"initialize","(Lorg/mozilla/pluglet/mozilla/PlugletManager;)V");
|
||||
if (!initializeMID) {
|
||||
env->ExceptionDescribe();
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
}
|
||||
if (!jthis) {
|
||||
jthis = PlugletLoader::GetPluglet(path);
|
||||
if (!jthis) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
env->CallVoidMethod(jthis,initializeMID,PlugletEngine::GetPlugletManager());
|
||||
if (env->ExceptionOccurred()) {
|
||||
env->ExceptionDescribe();
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult PlugletFactory::Shutdown(void) {
|
||||
|
||||
if(!jthis) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
JNIEnv *env = PlugletEngine::GetJNIEnv();
|
||||
if(!env) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
env->CallVoidMethod(jthis,shutdownMID);
|
||||
if (env->ExceptionOccurred()) {
|
||||
env->ExceptionDescribe();
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult PlugletFactory::GetMIMEDescription(const char* *result) {
|
||||
if(!result) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
*result = mimeDescription;
|
||||
return (*result) ? NS_OK : NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
PlugletFactory::PlugletFactory(const char *mimeDescription, const char *path) {
|
||||
jthis = NULL;
|
||||
this->path = new char[strlen(path)+1];
|
||||
strcpy(this->path,path);
|
||||
this->mimeDescription = new char[strlen(mimeDescription)+1];
|
||||
strcpy(this->mimeDescription,mimeDescription);
|
||||
|
||||
}
|
||||
|
||||
PlugletFactory::~PlugletFactory(void) {
|
||||
if (path != NULL) {
|
||||
delete[] path;
|
||||
}
|
||||
if (mimeDescription != NULL) {
|
||||
delete[] mimeDescription;
|
||||
}
|
||||
JNIEnv *env = PlugletEngine::GetJNIEnv();
|
||||
if (env != NULL) {
|
||||
env->DeleteGlobalRef(jthis);
|
||||
}
|
||||
}
|
||||
|
||||
PlugletFactory * PlugletFactory::Load(const char * path) {
|
||||
char * mime = PlugletLoader::GetMIMEDescription(path);
|
||||
PlugletFactory * result = NULL;
|
||||
if (mime) {
|
||||
result = new PlugletFactory(mime,path);
|
||||
//delete[] mime; //nb we have a strange exception here
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/*
|
||||
1 if good
|
||||
0 if not good
|
||||
*/
|
||||
int PlugletFactory::Compare(const char *mimeType) {
|
||||
/* mimedDescription mimeTypes:extensions:description
|
||||
mimeTypes mimeType;mimeType;...
|
||||
extensions extension;extension;...
|
||||
*/
|
||||
if (!mimeType) {
|
||||
return 0;
|
||||
}
|
||||
char * terminator = strchr(mimeDescription,':'); // terminator have to be not equal to NULL;
|
||||
char *p1 = mimeDescription;
|
||||
char *p2 = strchr(p1,';');
|
||||
while ( p1 != NULL && p1 < terminator ) {
|
||||
size_t n = sizeof(char) * ( ( (p2 == NULL) ? terminator : p2) - p1 );
|
||||
if (PL_strncasecmp(p1,mimeType,n) == 0) {
|
||||
return 1;
|
||||
}
|
||||
p1 = p2 ;
|
||||
if (p2 != NULL) {
|
||||
p2 = strchr(++p2,';');
|
||||
p1++;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
47
mozilla/java/plugins/src/PlugletFactory.h
Normal file
47
mozilla/java/plugins/src/PlugletFactory.h
Normal file
@@ -0,0 +1,47 @@
|
||||
/*
|
||||
* 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 Sun Microsystems,
|
||||
* Inc. Portions created by Sun are
|
||||
* Copyright (C) 1999 Sun Microsystems, Inc. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*/
|
||||
#ifndef __PlugletFactory_h__
|
||||
#define __PlugletFactory_h__
|
||||
#include "nsplugin.h"
|
||||
#include "jni.h"
|
||||
|
||||
class PlugletFactory {
|
||||
public:
|
||||
nsresult CreatePluginInstance(const char* aPluginMIMEType, void **aResult);
|
||||
nsresult Initialize(void);
|
||||
nsresult Shutdown(void);
|
||||
nsresult GetMIMEDescription(const char* *result);
|
||||
/*****************************************/
|
||||
~PlugletFactory(void);
|
||||
int Compare(const char * mimeType);
|
||||
static PlugletFactory * Load(const char * path);
|
||||
private:
|
||||
jobject jthis;
|
||||
static jmethodID createPlugletMID;
|
||||
static jmethodID initializeMID;
|
||||
static jmethodID shutdownMID;
|
||||
/*****************************************/
|
||||
char *mimeDescription;
|
||||
char *path;
|
||||
PlugletFactory(const char *mimeDescription,const char * path);
|
||||
};
|
||||
|
||||
#endif /* __PlugletFactory_h__ */
|
||||
@@ -1,146 +0,0 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
* 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 Sun Microsystems,
|
||||
* Inc. Portions created by Sun are
|
||||
* Copyright (C) 1999 Sun Microsystems, Inc. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*/
|
||||
#include "PlugletInstance.h"
|
||||
#include "PlugletEngine.h"
|
||||
#include "PlugletStreamListener.h"
|
||||
#include "PlugletInstancePeer.h"
|
||||
#include "Registry.h"
|
||||
|
||||
jmethodID PlugletInstance::initializeMID = NULL;
|
||||
jmethodID PlugletInstance::startMID = NULL;
|
||||
jmethodID PlugletInstance::stopMID = NULL;
|
||||
jmethodID PlugletInstance::destroyMID = NULL;
|
||||
jmethodID PlugletInstance::newStreamMID = NULL;
|
||||
jmethodID PlugletInstance::setWindowMID = NULL;
|
||||
jmethodID PlugletInstance::printMID = NULL;
|
||||
|
||||
static NS_DEFINE_IID(kIPluginInstanceIID, NS_IPLUGININSTANCE_IID);
|
||||
|
||||
NS_IMPL_ISUPPORTS(PlugletInstance, kIPluginInstanceIID);
|
||||
|
||||
PlugletInstance::PlugletInstance(jobject object) {
|
||||
NS_INIT_REFCNT();
|
||||
jthis = PlugletEngine::GetJNIEnv()->NewGlobalRef(object);
|
||||
//nb check for null
|
||||
peer = NULL;
|
||||
view = new PlugletInstanceView();
|
||||
Registry::SetPeer(jthis,(jlong)this);
|
||||
}
|
||||
|
||||
PlugletInstance::~PlugletInstance() {
|
||||
Registry::Remove(jthis);
|
||||
PlugletEngine::GetJNIEnv()->DeleteGlobalRef(jthis);
|
||||
NS_RELEASE(peer);
|
||||
}
|
||||
|
||||
NS_METHOD PlugletInstance::HandleEvent(nsPluginEvent* event, PRBool* handled) {
|
||||
//nb we do not need it under win32
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_METHOD PlugletInstance::Initialize(nsIPluginInstancePeer* _peer) {
|
||||
JNIEnv *env = PlugletEngine::GetJNIEnv();
|
||||
if (!printMID) {
|
||||
//nb check for null after each and every JNI call
|
||||
jclass clazz = env->FindClass("org/mozilla/pluglet/PlugletInstance");
|
||||
initializeMID = env->GetMethodID(clazz,"initialize","(Lorg/mozilla/pluglet/mozilla/PlugletInstancePeer;)V");
|
||||
startMID = env->GetMethodID(clazz,"start","()V");
|
||||
stopMID = env->GetMethodID(clazz,"stop","()V");
|
||||
destroyMID = env->GetMethodID(clazz,"destroy","()V");
|
||||
newStreamMID = env->GetMethodID(clazz,"newStream","()Lorg/mozilla/pluglet/PlugletStreamListener;");
|
||||
setWindowMID = env->GetMethodID(clazz,"setWindow","(Ljava/awt/Frame;)V");
|
||||
printMID = env->GetMethodID(clazz,"print","(Ljava/awt/print/PrinterJob;)V");
|
||||
}
|
||||
peer = _peer;
|
||||
peer->AddRef();
|
||||
jobject obj = PlugletInstancePeer::GetJObject(peer);
|
||||
if (!obj) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
env->CallVoidMethod(jthis,initializeMID,obj);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_METHOD PlugletInstance::GetPeer(nsIPluginInstancePeer* *result) {
|
||||
peer->AddRef();
|
||||
*result = peer;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_METHOD PlugletInstance::Start(void) {
|
||||
JNIEnv * env = PlugletEngine::GetJNIEnv();
|
||||
env->CallVoidMethod(jthis,startMID);
|
||||
//nb check for JNI exception
|
||||
return NS_OK;
|
||||
}
|
||||
NS_METHOD PlugletInstance::Stop(void) {
|
||||
JNIEnv * env = PlugletEngine::GetJNIEnv();
|
||||
env->CallVoidMethod(jthis,stopMID);
|
||||
//nb check for JNI exception
|
||||
return NS_OK;
|
||||
}
|
||||
NS_METHOD PlugletInstance::Destroy(void) {
|
||||
JNIEnv * env = PlugletEngine::GetJNIEnv();
|
||||
env->CallVoidMethod(jthis,destroyMID);
|
||||
//nb check for JNI exception
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_METHOD PlugletInstance::NewStream(nsIPluginStreamListener** listener) {
|
||||
if(!listener) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
JNIEnv * env = PlugletEngine::GetJNIEnv();
|
||||
jobject obj = env->CallObjectMethod(jthis,newStreamMID);
|
||||
//nb check for JNI exception
|
||||
if (obj) {
|
||||
*listener = new PlugletStreamListener(obj);
|
||||
(*listener)->AddRef();
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_METHOD PlugletInstance::GetValue(nsPluginInstanceVariable variable, void *value) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
NS_METHOD PlugletInstance::SetWindow(nsPluginWindow* window) {
|
||||
JNIEnv *env = PlugletEngine::GetJNIEnv();
|
||||
if (view->SetWindow(window)) {
|
||||
env->CallVoidMethod(jthis,setWindowMID,view->GetJObject());
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_METHOD PlugletInstance::Print(nsPluginPrint* platformPrint) {
|
||||
//nb
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -1,63 +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 mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Sun Microsystems,
|
||||
* Inc. Portions created by Sun are
|
||||
* Copyright (C) 1999 Sun Microsystems, Inc. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*/
|
||||
#ifndef __PlugletInstance_h__
|
||||
#define __PlugletInstance_h__
|
||||
#include "nsplugin.h"
|
||||
#include "jni.h"
|
||||
#include "PlugletInstanceView.h"
|
||||
|
||||
class PlugletInstance : public nsIPluginInstance {
|
||||
public:
|
||||
NS_IMETHOD HandleEvent(nsPluginEvent* event, PRBool* handled);
|
||||
NS_IMETHOD Initialize(nsIPluginInstancePeer* peer);
|
||||
NS_IMETHOD GetPeer(nsIPluginInstancePeer* *result);
|
||||
NS_IMETHOD Start(void);
|
||||
NS_IMETHOD Stop(void);
|
||||
NS_IMETHOD Destroy(void);
|
||||
NS_IMETHOD NewStream(nsIPluginStreamListener** listener);
|
||||
NS_IMETHOD SetWindow(nsPluginWindow* window);
|
||||
NS_IMETHOD Print(nsPluginPrint* platformPrint);
|
||||
NS_IMETHOD GetValue(nsPluginInstanceVariable variable, void *value);
|
||||
NS_DECL_ISUPPORTS
|
||||
|
||||
PlugletInstance(jobject object);
|
||||
virtual ~PlugletInstance(void);
|
||||
private:
|
||||
jobject jthis;
|
||||
static jmethodID initializeMID;
|
||||
static jmethodID startMID;
|
||||
static jmethodID stopMID;
|
||||
static jmethodID destroyMID;
|
||||
static jmethodID newStreamMID;
|
||||
static jmethodID setWindowMID;
|
||||
static jmethodID printMID;
|
||||
static jmethodID getValueMID;
|
||||
nsIPluginInstancePeer *peer;
|
||||
PlugletInstanceView *view;
|
||||
};
|
||||
#endif /* __PlugletInstance_h__ */
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -1,72 +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 mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Sun Microsystems,
|
||||
* Inc. Portions created by Sun are
|
||||
* Copyright (C) 1999 Sun Microsystems, Inc. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*/
|
||||
#include"PlugletList.h"
|
||||
|
||||
PlugletList::PlugletList() {
|
||||
head = tail = NULL;
|
||||
}
|
||||
|
||||
PlugletList::~PlugletList() {
|
||||
for(PlugletListNode * current=head;!current;delete current,current = current->next)
|
||||
;
|
||||
}
|
||||
|
||||
PlugletList::PlugletListNode::PlugletListNode(Pluglet *v,PlugletList::PlugletListNode *n) {
|
||||
value = v; next = n;
|
||||
}
|
||||
|
||||
void PlugletList::Add(Pluglet *pluglet) {
|
||||
if (!pluglet) {
|
||||
return;
|
||||
}
|
||||
if (!tail) {
|
||||
head = tail = new PlugletListNode(pluglet);
|
||||
} else {
|
||||
tail->next = new PlugletListNode(pluglet);
|
||||
if (tail->next) {
|
||||
tail = tail->next;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
PlugletListIterator * PlugletList::GetIterator(void) {
|
||||
return new PlugletListIterator(this);
|
||||
}
|
||||
|
||||
PlugletListIterator::PlugletListIterator(PlugletList *list) {
|
||||
current = list->head;
|
||||
}
|
||||
Pluglet * PlugletListIterator::Get(void) {
|
||||
Pluglet * result = NULL;
|
||||
if (current) {
|
||||
result = current->value;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
Pluglet * PlugletListIterator::Next(void) {
|
||||
Pluglet * result = NULL;
|
||||
if (current) {
|
||||
current = current->next;
|
||||
result = Get();
|
||||
}
|
||||
return result;
|
||||
}
|
||||
@@ -1,51 +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 mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Sun Microsystems,
|
||||
* Inc. Portions created by Sun are
|
||||
* Copyright (C) 1999 Sun Microsystems, Inc. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*/
|
||||
#ifndef __PlugletList_h__
|
||||
#define __PlugletList_h__
|
||||
#include "Pluglet.h"
|
||||
class PlugletListIterator;
|
||||
|
||||
class PlugletList {
|
||||
friend class PlugletListIterator;
|
||||
public:
|
||||
PlugletList();
|
||||
~PlugletList();
|
||||
void Add(Pluglet *pluglet);
|
||||
PlugletListIterator * GetIterator(void);
|
||||
private:
|
||||
struct PlugletListNode {
|
||||
PlugletListNode(Pluglet *v,PlugletListNode *n = NULL);
|
||||
Pluglet * value;
|
||||
PlugletListNode * next;
|
||||
};
|
||||
PlugletListNode * head;
|
||||
PlugletListNode * tail;
|
||||
};
|
||||
class PlugletListIterator {
|
||||
public:
|
||||
PlugletListIterator(PlugletList *list);
|
||||
Pluglet * Get(void);
|
||||
Pluglet * Next(void);
|
||||
private:
|
||||
PlugletList::PlugletListNode *current;
|
||||
};
|
||||
|
||||
#endif /* __PlugletList_h__ */
|
||||
@@ -59,7 +59,7 @@ void PlugletLoader::Initialize(void) {
|
||||
clazz = NULL;
|
||||
return;
|
||||
}
|
||||
getPlugletMID = env->GetStaticMethodID(clazz,"getPluglet","(Ljava/lang/String;)Lorg/mozilla/pluglet/Pluglet;");
|
||||
getPlugletMID = env->GetStaticMethodID(clazz,"getPluglet","(Ljava/lang/String;)Lorg/mozilla/pluglet/PlugletFactory;");
|
||||
if (env->ExceptionOccurred()) {
|
||||
env->ExceptionDescribe();
|
||||
clazz = NULL;
|
||||
|
||||
@@ -19,15 +19,15 @@
|
||||
* Contributor(s):
|
||||
*/
|
||||
#include "nsISupports.h"
|
||||
#include "PlugletInstancePeer.h"
|
||||
#include "PlugletPeer.h"
|
||||
#include "PlugletEngine.h"
|
||||
|
||||
jclass PlugletInstancePeer::clazz = NULL;
|
||||
jmethodID PlugletInstancePeer::initMID = NULL;
|
||||
jclass PlugletPeer::clazz = NULL;
|
||||
jmethodID PlugletPeer::initMID = NULL;
|
||||
|
||||
void PlugletInstancePeer::Initialize(void) {
|
||||
void PlugletPeer::Initialize(void) {
|
||||
JNIEnv * env = PlugletEngine::GetJNIEnv();
|
||||
clazz = env->FindClass("org/mozilla/pluglet/mozilla/PlugletInstancePeerImpl");
|
||||
clazz = env->FindClass("org/mozilla/pluglet/mozilla/PlugletPeerImpl");
|
||||
if (env->ExceptionOccurred()) {
|
||||
env->ExceptionDescribe();
|
||||
clazz = NULL;
|
||||
@@ -43,7 +43,7 @@ void PlugletInstancePeer::Initialize(void) {
|
||||
}
|
||||
}
|
||||
|
||||
void PlugletInstancePeer::Destroy(void) {
|
||||
void PlugletPeer::Destroy(void) {
|
||||
//nb who gonna cal it?
|
||||
JNIEnv * env = PlugletEngine::GetJNIEnv();
|
||||
if(clazz) {
|
||||
@@ -51,7 +51,7 @@ void PlugletInstancePeer::Destroy(void) {
|
||||
}
|
||||
}
|
||||
|
||||
jobject PlugletInstancePeer::GetJObject(const nsIPluginInstancePeer *stream) {
|
||||
jobject PlugletPeer::GetJObject(const nsIPluginInstancePeer *peer) {
|
||||
jobject res = NULL;
|
||||
JNIEnv *env = PlugletEngine::GetJNIEnv();
|
||||
if(!clazz) {
|
||||
@@ -60,7 +60,7 @@ jobject PlugletInstancePeer::GetJObject(const nsIPluginInstancePeer *stream) {
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
res = env->NewObject(clazz,initMID,(jlong)stream);
|
||||
res = env->NewObject(clazz,initMID,(jlong)peer);
|
||||
if (env->ExceptionOccurred()) {
|
||||
env->ExceptionDescribe();
|
||||
res = NULL;
|
||||
@@ -18,12 +18,12 @@
|
||||
*
|
||||
* Contributor(s):
|
||||
*/
|
||||
#ifndef __PlugletInstancePeer_h__
|
||||
#define __PlugletInstancePeer_h__
|
||||
#ifndef __PlugletPeer_h__
|
||||
#define __PlugletPeer_h__
|
||||
#include "nsIPluginInstancePeer.h"
|
||||
#include "jni.h"
|
||||
|
||||
class PlugletInstancePeer {
|
||||
class PlugletPeer {
|
||||
public:
|
||||
static jobject GetJObject(const nsIPluginInstancePeer *instancePeer);
|
||||
private:
|
||||
@@ -32,4 +32,4 @@ class PlugletInstancePeer {
|
||||
static jclass clazz;
|
||||
static jmethodID initMID;
|
||||
};
|
||||
#endif /* __PlugletInputStream_h__ */
|
||||
#endif /* __PlugletPeer_h__ */
|
||||
@@ -1,4 +1,4 @@
|
||||
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
/*
|
||||
* 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
|
||||
@@ -19,19 +19,19 @@
|
||||
* Contributor(s):
|
||||
*/
|
||||
#include <windows.h>
|
||||
#include "PlugletInstanceView.h"
|
||||
#include "PlugletView.h"
|
||||
#include "PlugletEngine.h"
|
||||
|
||||
|
||||
jclass PlugletInstanceView::clazz = NULL;
|
||||
jmethodID PlugletInstanceView::initMID = NULL;
|
||||
jclass PlugletView::clazz = NULL;
|
||||
jmethodID PlugletView::initMID = NULL;
|
||||
|
||||
PlugletInstanceView::PlugletInstanceView() {
|
||||
PlugletView::PlugletView() {
|
||||
hWND = NULL;
|
||||
frame = NULL;
|
||||
isCreated = FALSE;
|
||||
}
|
||||
void PlugletInstanceView::Initialize() {
|
||||
void PlugletView::Initialize() {
|
||||
JNIEnv *env = PlugletEngine::GetJNIEnv();
|
||||
clazz = env->FindClass("sun/awt/windows/WEmbeddedFrame");
|
||||
if (!clazz) {
|
||||
@@ -46,7 +46,7 @@ void PlugletInstanceView::Initialize() {
|
||||
}
|
||||
}
|
||||
|
||||
BOOLEAN PlugletInstanceView::SetWindow(nsPluginWindow* window) {
|
||||
BOOLEAN PlugletView::SetWindow(nsPluginWindow* window) {
|
||||
if (!window || !window->window) {
|
||||
if (isCreated) {
|
||||
isCreated = FALSE;
|
||||
@@ -78,7 +78,7 @@ BOOLEAN PlugletInstanceView::SetWindow(nsPluginWindow* window) {
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
jobject PlugletInstanceView::GetJObject() {
|
||||
jobject PlugletView::GetJObject() {
|
||||
return frame;
|
||||
}
|
||||
|
||||
@@ -18,15 +18,15 @@
|
||||
*
|
||||
* Contributor(s):
|
||||
*/
|
||||
#ifndef __PlugletInstanceView_h__
|
||||
#define __PlugletInstanceView_h__
|
||||
#ifndef __PlugletView_h__
|
||||
#define __PlugletView_h__
|
||||
#include <windows.h>
|
||||
#include "nsplugindefs.h"
|
||||
#include "jni.h"
|
||||
|
||||
class PlugletInstanceView {
|
||||
class PlugletView {
|
||||
public:
|
||||
PlugletInstanceView(void);
|
||||
PlugletView(void);
|
||||
jobject GetJObject(void);
|
||||
BOOLEAN SetWindow(nsPluginWindow* window);
|
||||
private:
|
||||
@@ -28,7 +28,7 @@ PlugletsDir::PlugletsDir(void) {
|
||||
|
||||
PlugletsDir::~PlugletsDir(void) {
|
||||
if (list) {
|
||||
for (PlugletListIterator *iter = list->GetIterator();iter->Get();delete iter->Get(),iter->Next())
|
||||
for (ListIterator *iter = list->GetIterator();iter->Get();delete iter->Get(),iter->Next())
|
||||
;
|
||||
delete list;
|
||||
}
|
||||
@@ -36,10 +36,10 @@ PlugletsDir::~PlugletsDir(void) {
|
||||
|
||||
void PlugletsDir::LoadPluglets() {
|
||||
if (!list) {
|
||||
list = new PlugletList();
|
||||
list = new List();
|
||||
char * path = PR_GetEnv("PLUGLET");
|
||||
int pathLength = strlen(path);
|
||||
Pluglet *pluglet;
|
||||
PlugletFactory *plugletFactory;
|
||||
nsFileSpec dir(path);
|
||||
for (nsDirectoryIterator iter(dir,PR_TRUE); iter.Exists(); iter++) {
|
||||
const nsFileSpec& file = iter;
|
||||
@@ -49,25 +49,25 @@ void PlugletsDir::LoadPluglets() {
|
||||
|| strcmp(name+length - 4,".jar") ) {
|
||||
continue;
|
||||
}
|
||||
if ( (pluglet = Pluglet::Load(name)) ) {
|
||||
list->Add(pluglet);
|
||||
if ( (plugletFactory = PlugletFactory::Load(name)) ) {
|
||||
list->Add(plugletFactory);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
nsresult PlugletsDir::GetPluglet(const char * mimeType, Pluglet **pluglet) {
|
||||
if(!pluglet) {
|
||||
nsresult PlugletsDir::GetPlugletFactory(const char * mimeType, PlugletFactory **plugletFactory) {
|
||||
if(!plugletFactory) {
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
}
|
||||
*pluglet = NULL;
|
||||
*plugletFactory = NULL;
|
||||
nsresult res = NS_ERROR_FAILURE;
|
||||
if(!list) {
|
||||
LoadPluglets();
|
||||
}
|
||||
for (PlugletListIterator *iter = list->GetIterator();iter->Get();iter->Next()) {
|
||||
if(iter->Get()->Compare(mimeType)) {
|
||||
*pluglet = iter->Get();
|
||||
for (ListIterator *iter = list->GetIterator();iter->Get();iter->Next()) {
|
||||
if(((PlugletFactory*)(iter->Get()))->Compare(mimeType)) {
|
||||
*plugletFactory = (PlugletFactory*)iter->Get();
|
||||
res = NS_OK;
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -20,8 +20,8 @@
|
||||
*/
|
||||
#ifndef __PlugletsDir_h__
|
||||
#define __PlugletsDir_h__
|
||||
#include "Pluglet.h"
|
||||
#include "PlugletList.h"
|
||||
#include "PlugletFactory.h"
|
||||
#include "List.h"
|
||||
|
||||
class PlugletsDir {
|
||||
friend class PlugletsDirIterator;
|
||||
@@ -29,9 +29,9 @@ class PlugletsDir {
|
||||
PlugletsDir(void);
|
||||
~PlugletsDir(void);
|
||||
void LoadPluglets();
|
||||
nsresult GetPluglet(const char * mimeType,Pluglet **pluglet);
|
||||
nsresult GetPlugletFactory(const char * mimeType,PlugletFactory **plugletFactory);
|
||||
private:
|
||||
PlugletList * list;
|
||||
List * list;
|
||||
};
|
||||
#endif /* __PlugletsDir_h__ */
|
||||
|
||||
|
||||
@@ -53,16 +53,16 @@ REQUIRES = java plug xpcom raptor
|
||||
OBJS = \
|
||||
.\$(OBJDIR)\Pluglet.obj \
|
||||
.\$(OBJDIR)\PlugletEngine.obj \
|
||||
.\$(OBJDIR)\PlugletList.obj \
|
||||
.\$(OBJDIR)\List.obj \
|
||||
.\$(OBJDIR)\PlugletLoader.obj \
|
||||
.\$(OBJDIR)\PlugletsDir.obj \
|
||||
.\$(OBJDIR)\PlugletInstance.obj \
|
||||
.\$(OBJDIR)\PlugletFactory.obj \
|
||||
.\$(OBJDIR)\PlugletStreamListener.obj \
|
||||
.\$(OBJDIR)\PlugletStreamInfo.obj \
|
||||
.\$(OBJDIR)\PlugletInstancePeer.obj \
|
||||
.\$(OBJDIR)\PlugletPeer.obj \
|
||||
.\$(OBJDIR)\PlugletManager.obj \
|
||||
.\$(OBJDIR)\PlugletInputStream.obj \
|
||||
.\$(OBJDIR)\PlugletInstanceView.obj \
|
||||
.\$(OBJDIR)\PlugletView.obj \
|
||||
!ifndef OJI_DISABLE
|
||||
.\$(OBJDIR)\PlugletSecurityContext.obj \
|
||||
!endif
|
||||
|
||||
Reference in New Issue
Block a user