/* gcjwebplugin - Webbrowser plugin to execute Java (tm) applets. Copyright (C) 2003 Michael Koch This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA Linking this library statically or dynamically with other modules is making a combined work based on this library. Thus, the terms and conditions of the GNU General Public License cover the whole combination. As a special exception, the copyright holders of this library give you permission to link this library with independent modules to produce an executable, regardless of the license terms of these independent modules, and to copy and distribute the resulting executable under terms of your choice, provided that you also meet, for each linked independent module, the terms and conditions of the license of that module. An independent module is a module which is not derived from or based on this library. If you modify this library, you may extend this exception to your version of the library, but you are not obligated to do so. If you do not wish to do so, delete this exception statement from your version. */ #include #include #include "GCJPluginInstance.h" #define DEBUG(output) printf (output); #define DEBUG2(output, arg) printf (output, arg); #define ENV m_jniEnv #define CHECK_EXCEPTIONS \ if (m_jniEnv->ExceptionOccurred ()) \ { \ m_jniEnv->ExceptionDescribe (); \ m_jniEnv->ExceptionClear (); \ } NS_IMPL_ISUPPORTS1 (GCJPluginInstance, nsIJVMPluginInstance) GCJPluginInstance::GCJPluginInstance (GCJPluginFactory* factory, JNIEnv* jniEnv) : m_peer (NULL) , m_jniEnv (jniEnv) , m_windowCreated (0) , m_Applet (NULL) { DEBUG ("GCJPluginInstance::GCJPluginInstance\n"); } GCJPluginInstance::~GCJPluginInstance () { DEBUG ("GCJPluginInstance::~GCJPluginInstance\n"); } NS_IMETHODIMP GCJPluginInstance::Initialize (nsIPluginInstancePeer* peer) { DEBUG ("GCJPluginInstance::Initialize\n"); m_peer = peer; m_peer->AddRef (); return NS_OK; } NS_IMETHODIMP GCJPluginInstance::GetPeer (nsIPluginInstancePeer** result) { DEBUG ("GCJPluginInstance::GetPeer\n"); (*result) = m_peer; return NS_OK; } NS_IMETHODIMP GCJPluginInstance::Start () { DEBUG ("GCJPluginInstance::Start\n"); /* jmethodID startMethod = m_jniEnv->GetMethodID (m_class_Applet, "start", "()V"); assert (startMethod != NULL); m_jniEnv->CallVoidMethod (m_Applet, startMethod); CHECK_EXCEPTIONS */ return NS_OK; } NS_IMETHODIMP GCJPluginInstance::Stop () { DEBUG ("GCJPluginInstance::Stop\n"); /* jmethodID stopMethod = m_jniEnv->GetMethodID (m_class_Applet, "stop", "()V"); assert (stopMethod != NULL); m_jniEnv->CallVoidMethod (m_Applet, stopMethod); CHECK_EXCEPTIONS */ return NS_OK; } NS_IMETHODIMP GCJPluginInstance::Destroy () { DEBUG ("GCJPluginInstance::Destroy\n"); return NS_ERROR_NOT_IMPLEMENTED; } NS_IMETHODIMP GCJPluginInstance::SetWindow (nsPluginWindow* window) { DEBUG ("GCJPluginInstance::SetWindow\n"); if (!m_windowCreated) { jclass class_EmbeddedWindow = m_jniEnv->FindClass ("gnu/java/awt/EmbeddedWindow"); jmethodID method_EmbeddedWindow_init = m_jniEnv->GetMethodID (class_EmbeddedWindow, "", "(III)V"); m_embeddedWindow = m_jniEnv->NewObject (class_EmbeddedWindow, method_EmbeddedWindow_init, (jint) window->window, (jint) window->width, (jint) window->height); } return NS_OK; } NS_IMETHODIMP GCJPluginInstance::NewStream (nsIPluginStreamListener** listener) { DEBUG ("GCJPluginInstance::NewStream\n"); return NS_OK; } NS_IMETHODIMP GCJPluginInstance::Print (nsPluginPrint* platformPrint) { DEBUG ("GCJPluginInstance::Print\n"); return NS_OK; } NS_IMETHODIMP GCJPluginInstance::GetValue (nsPluginInstanceVariable variable, void* value) { DEBUG2 ("GCJPluginInstance::GetValue: variable: %i\n", variable); switch (variable) { case nsPluginInstanceVariable_WindowlessBool: *(PRBool*) value = PR_FALSE; break; case nsPluginInstanceVariable_TransparentBool: *(PRBool*) value = PR_FALSE; break; case nsPluginInstanceVariable_DoCacheBool: *(PRBool*) value = PR_FALSE; break; case nsPluginInstanceVariable_CallSetWindowAfterDestroyBool: *(PRBool*) value = PR_FALSE; break; default: DEBUG ("GCJPluginInstance::GetValue: Requested unknown value\n"); return NS_ERROR_NOT_IMPLEMENTED; } return NS_OK; } NS_IMETHODIMP GCJPluginInstance::HandleEvent (nsPluginEvent* event, PRBool* handled) { DEBUG ("GCJPluginInstance::HandleEvent\n"); (*handled) = PR_TRUE; return NS_OK; } NS_IMETHODIMP GCJPluginInstance::GetJavaObject (jobject* result) { DEBUG ("GCJPluginInstance::GetJavaObject\n"); (*result) = (jobject) m_Applet; return NS_OK; } NS_IMETHODIMP GCJPluginInstance::GetText (const char** result) { DEBUG ("GCJPluginInstance::GetText\n"); return NS_OK; }