Back to index

lightning-sunbird  0.9+nobinonly
Public Member Functions | Private Member Functions | Private Attributes | Static Private Attributes
MRJConsole Class Reference

#include <MRJConsole.h>

Inheritance diagram for MRJConsole:
Inheritance graph
[legend]
Collaboration diagram for MRJConsole:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 MRJConsole (MRJPlugin *plugin)
virtual ~MRJConsole ()
NS_IMETHOD QueryInterface (REFNSIID aIID, void **aInstancePtr)
 NS_IMETHOD_ (nsrefcnt) AddRef(void)
 NS_IMETHOD_ (nsrefcnt) Release(void)
NS_IMETHOD Show (void)
NS_IMETHOD Hide (void)
NS_IMETHOD IsVisible (PRBool *isVisible)
NS_IMETHOD Print (const char *msg, const char *encodingName=NULL)
NS_IMETHOD HandleEvent (nsPluginEvent *event, PRBool *eventHandled)
void setFrame (TopLevelFrame *frame)
void write (const void *message, UInt32 messageLengthInBytes)
 MRJConsole (MRJPlugin *plugin)
virtual ~MRJConsole ()
NS_IMETHOD QueryInterface (REFNSIID aIID, void **aInstancePtr)
 NS_IMETHOD_ (nsrefcnt) AddRef(void)
 NS_IMETHOD_ (nsrefcnt) Release(void)
NS_IMETHOD Show (void)
NS_IMETHOD Hide (void)
NS_IMETHOD IsVisible (PRBool *isVisible)
NS_IMETHOD Print (const char *msg, const char *encodingName=NULL)
NS_IMETHOD HandleEvent (nsPluginEvent *event, PRBool *eventHandled)
void setFrame (TopLevelFrame *frame)
void write (const void *message, UInt32 messageLengthInBytes)
void handleEvent (in nsPluginEventPtr aEvent, out boolean aHandled)
 Handles an event.
nsresult queryInterface (const nsIID &aIID, void **aInstancePtr)
 The lowercase implementations of queryInterface, addRef, and release all act locally on the current object, regardless of aggregation.
nsresult queryInterface (const nsIID &aIID, void **aInstancePtr)
nsrefcnt addRef (void)
nsrefcnt addRef (void)
nsrefcnt release (void)
nsrefcnt release (void)

Private Member Functions

OSStatus CallConsoleMethod (jmethodID method)
OSStatus CallConsoleMethod (jmethodID method, jobject arg)
void Initialize ()
OSStatus CallConsoleMethod (jmethodID method)
OSStatus CallConsoleMethod (jmethodID method, jobject arg)
void Initialize ()

Private Attributes

MRJPluginmPlugin
MRJSessionmSession
PRBool mIsInitialized
jclass mConsoleClass
jmethodID mInitMethod
jmethodID mDisposeMethod
jmethodID mShowMethod
jmethodID mHideMethod
jmethodID mVisibleMethod
jmethodID mPrintMethod
jmethodID mFinishMethod
jbooleanArray mResults
JMAWTContextRef mContext
TopLevelFramemFrame

Static Private Attributes

static const InterfaceInfo sInterfaces []
static const UInt32 kInterfaceCount = sizeof(sInterfaces) / sizeof(InterfaceInfo)

Detailed Description

Definition at line 60 of file MRJConsole.h.


Constructor & Destructor Documentation

MRJConsole::~MRJConsole ( ) [virtual]

Definition at line 77 of file MRJConsole.cpp.

Here is the call graph for this function:

virtual MRJConsole::~MRJConsole ( ) [virtual]

Member Function Documentation

nsrefcnt SupportsMixin::addRef ( void  ) [inherited]

Here is the caller graph for this function:

nsrefcnt SupportsMixin::addRef ( void  ) [inherited]
OSStatus MRJConsole::CallConsoleMethod ( jmethodID  method,
jobject  arg 
) [private]

Definition at line 238 of file MRJConsole.cpp.

{
       JNIEnv* env = mSession->getCurrentEnv();
       OSStatus status = JMExecJNIStaticMethodInContext(mContext, env, mConsoleClass, method, 0, NULL);
       env->CallStaticVoidMethod(mConsoleClass, mFinishMethod);
       return status;
}

Here is the call graph for this function:

Here is the caller graph for this function:

OSStatus MRJConsole::CallConsoleMethod ( jmethodID  method,
jobject  arg 
) [private]

Definition at line 246 of file MRJConsole.cpp.

{
       jvalue args[1];
       args[0].l = arg;
       JNIEnv* env = mSession->getCurrentEnv();
       OSStatus status = JMExecJNIStaticMethodInContext(mContext, env, mConsoleClass, method, 1, args);
       env->CallStaticVoidMethod(mConsoleClass, mFinishMethod);
       return status;
}

Here is the call graph for this function:

void nsIEventHandler::handleEvent ( in nsPluginEventPtr  aEvent,
out boolean  aHandled 
) [inherited]

Handles an event.

An nsIEventHandler can also get registered with with nsIPluginManager2::RegisterWindow and will be called whenever an event comes in for that window.

Note that for Unix and Mac the nsPluginEvent structure is different from the old NPEvent structure -- it's no longer the native event record, but is instead a struct. This was done for future extensibility, and so that the Mac could receive the window argument too. For Windows and OS2, it's always been a struct, so there's no change for them.

(Corresponds to NPP_HandleEvent.)

Parameters:
aEvent- the event to be handled
aHandled- set to PR_TRUE if event was handled
Returns:
- NS_OK if this operation was successful
NS_IMETHOD MRJConsole::HandleEvent ( nsPluginEvent event,
PRBool eventHandled 
)
NS_METHOD MRJConsole::HandleEvent ( nsPluginEvent event,
PRBool eventHandled 
)

Definition at line 196 of file MRJConsole.cpp.

{
       *eventHandled = PR_TRUE;

       if (pluginEvent != NULL) {
              EventRecord* event = pluginEvent->event;

              if (event->what == nullEvent) {
                     // Give MRJ another quantum of time.
                     MRJSession* session = mPlugin->getSession();
                     session->idle(kDefaultJMTime);
              } else {
                     TopLevelFrame* frame = mFrame;
                     if (frame != NULL) {
                            switch (event->what) {
                            case nsPluginEventType_GetFocusEvent:
                                   frame->focusEvent(true);
                                   break;
                            
                            case nsPluginEventType_LoseFocusEvent:
                                   frame->focusEvent(false);
                                   break;

                            case nsPluginEventType_AdjustCursorEvent:
                                   frame->idle(event->modifiers);
                                   break;
                            
                            case nsPluginEventType_MenuCommandEvent:
                                   frame->menuSelected(event->message, event->modifiers);
                                   break;
                            
                            default:
                                   *eventHandled = frame->handleEvent(event);
                                   break;
                            }
                     }
              }
       }
       
       return NS_OK;
}

Here is the call graph for this function:

NS_IMETHOD MRJConsole::Hide ( void  ) [virtual]

Implements nsIJVMConsole.

NS_METHOD MRJConsole::Hide ( void  ) [virtual]

Implements nsIJVMConsole.

Definition at line 127 of file MRJConsole.cpp.

Here is the call graph for this function:

void MRJConsole::Initialize ( void  ) [private]

Definition at line 349 of file MRJConsole.cpp.

{
       if (mIsInitialized)
              return;
       
       mSession = mPlugin->getSession();
       JNIEnv* env = mSession->getCurrentEnv();
       
       jclass consoleClass = env->FindClass("netscape/oji/MRJConsole");
       if (consoleClass == NULL) return;
       mConsoleClass = (jclass) env->NewGlobalRef(consoleClass);
       
       mInitMethod = env->GetStaticMethodID(consoleClass, "init", "()V");
       mDisposeMethod = env->GetStaticMethodID(consoleClass, "dispose", "()V");
       mShowMethod = env->GetStaticMethodID(consoleClass, "show", "()V");
       mHideMethod = env->GetStaticMethodID(consoleClass, "hide", "()V");
       mVisibleMethod = env->GetStaticMethodID(consoleClass, "visible", "([Z)V");
       mPrintMethod = env->GetStaticMethodID(consoleClass, "print", "(Ljava/lang/String;)V");
       mFinishMethod = env->GetStaticMethodID(consoleClass, "finish", "()V");
       
       jbooleanArray results = env->NewBooleanArray(1);
       mResults = (jbooleanArray) env->NewGlobalRef(results);
       env->DeleteLocalRef(results);
       
       // Create an AWT context to work in.
       
       JMAWTContextCallbacks callbacks = {
              kJMVersion,                                      /* should be set to kJMVersion */
              &requestFrame,                                   /* a new frame is being created. */
              &releaseFrame,                                   /* an existing frame is being destroyed. */
              &getUniqueMenuID,                         /* a new menu will be created with this id. */
              &exceptionOccurred,                       /* just some notification that some recent operation caused an exception.  You can't do anything really from here. */
       };
       OSStatus status = ::JMNewAWTContext(&mContext, mSession->getSessionRef(), &callbacks, this);

       // Finally, call the Java initialize method, and wait for it to complete.

       if (mInitMethod != NULL && status == noErr) {
              status = JMExecJNIStaticMethodInContext(mContext, env, consoleClass, mInitMethod, 0, NULL);
              env->CallStaticVoidMethod(mConsoleClass, mFinishMethod);
       }
       env->DeleteLocalRef(consoleClass);

       mIsInitialized = (status == noErr);

       if (mIsInitialized)
              theConsole = this;
}

Here is the call graph for this function:

Here is the caller graph for this function:

NS_IMETHOD MRJConsole::IsVisible ( PRBool isVisible) [virtual]

Implements nsIJVMConsole.

NS_METHOD MRJConsole::IsVisible ( PRBool isVisible) [virtual]

Implements nsIJVMConsole.

Definition at line 139 of file MRJConsole.cpp.

{
       // don't initialize here, because if we haven't been initialized, it can't be visible.
       *isVisible = PR_FALSE;
       if (mVisibleMethod != NULL) {
              CallConsoleMethod(mVisibleMethod, mResults);
              jboolean isCopy;
              JNIEnv* env = mSession->getCurrentEnv();
              jboolean* elements = env->GetBooleanArrayElements(mResults, &isCopy);
              *isVisible = elements[0];
              env->ReleaseBooleanArrayElements(mResults, elements, JNI_ABORT);
       }
       return NS_OK;
}

Here is the call graph for this function:

NS_IMETHOD MRJConsole::Print ( const char *  msg,
const char *  encodingName = NULL 
) [virtual]

Implements nsIJVMConsole.

NS_METHOD MRJConsole::Print ( const char *  msg,
const char *  encodingName = NULL 
) [virtual]

Implements nsIJVMConsole.

Definition at line 158 of file MRJConsole.cpp.

{
       Initialize();

       if (mPrintMethod != NULL) {
              JNIEnv* env = mSession->getCurrentEnv();
              jstring jmsg = env->NewStringUTF(msg);
              jvalue args[1]; args[0].l = jmsg;
              JMExecJNIStaticMethodInContext(mContext, env, mConsoleClass, mPrintMethod, 1, args);
              env->DeleteLocalRef(jmsg);
              return NS_OK;
       }
       
       return NS_ERROR_FAILURE;
}

Here is the call graph for this function:

NS_IMETHODIMP SupportsMixin::queryInterface ( const nsIID aIID,
void **  aInstancePtr 
) [inherited]

The lowercase implementations of queryInterface, addRef, and release all act locally on the current object, regardless of aggregation.

They are meant to be called by aggregating outer objects.

Definition at line 129 of file SupportsMixin.cpp.

{
       if (aInstancePtr == NULL) {
              return NS_ERROR_NULL_POINTER;
       }
       // first check to see if it's one of our known interfaces.
       // need to solve the non-left inheritance graph case.
       const InterfaceInfo* interfaces = mInterfaces;
       UInt32 count = mInterfaceCount;
       for (UInt32 i = 0; i < count; i++) {
              if (aIID.Equals(interfaces[i].mIID)) {
                     *aInstancePtr = (void*) (UInt32(mInstance) + interfaces[i].mOffset);
                     addRef();
                     return NS_OK;
              }
       }
       // finally, does the interface match nsISupports?
       static NS_DEFINE_IID(kISupportsIID, NS_ISUPPORTS_IID);
       if (aIID.Equals(kISupportsIID)) {
              *aInstancePtr = (void*) mInstance;
              addRef();
              return NS_OK;
       }
       return NS_NOINTERFACE;
}

Here is the call graph for this function:

Here is the caller graph for this function:

NS_IMETHOD MRJConsole::QueryInterface ( REFNSIID  aIID,
void **  aInstancePtr 
)
nsresult SupportsMixin::queryInterface ( const nsIID aIID,
void **  aInstancePtr 
) [inherited]
NS_IMETHOD MRJConsole::QueryInterface ( REFNSIID  aIID,
void **  aInstancePtr 
)

Here is the caller graph for this function:

void MRJConsole::setFrame ( TopLevelFrame frame) [inline]

Definition at line 91 of file MRJConsole.h.

{ mFrame = frame; }
void MRJConsole::setFrame ( TopLevelFrame frame) [inline]

Definition at line 95 of file MRJConsole.h.

{ mFrame = frame; }
NS_IMETHOD MRJConsole::Show ( void  ) [virtual]

Implements nsIJVMConsole.

NS_METHOD MRJConsole::Show ( void  ) [virtual]

Implements nsIJVMConsole.

Definition at line 115 of file MRJConsole.cpp.

Here is the call graph for this function:

void MRJConsole::write ( const void message,
UInt32  messageLengthInBytes 
)
void MRJConsole::write ( const void message,
UInt32  messageLengthInBytes 
)

Definition at line 176 of file MRJConsole.cpp.

{
       if (mPrintMethod != NULL) {
              char* buffer = new char[messageLengthInBytes + 1];
              if (buffer != NULL) {
                     memcpy(buffer, message, messageLengthInBytes);
                     buffer[messageLengthInBytes] = '\0';

                     JNIEnv* env = mSession->getCurrentEnv();
                     jstring jmsg = env->NewStringUTF(buffer);
                     if (jmsg != NULL) {
                            env->CallStaticVoidMethod(mConsoleClass, mPrintMethod, jmsg);
                            env->DeleteLocalRef(jmsg);
                     }

                     delete buffer;
              }
       }
}

Here is the call graph for this function:

Here is the caller graph for this function:


Member Data Documentation

static const UInt32 MRJConsole::kInterfaceCount = sizeof(sInterfaces) / sizeof(InterfaceInfo) [static, private]

Definition at line 127 of file MRJConsole.h.

Definition at line 111 of file MRJConsole.h.

JMAWTContextRef MRJConsole::mContext [private]

Definition at line 122 of file MRJConsole.h.

Definition at line 113 of file MRJConsole.h.

Definition at line 118 of file MRJConsole.h.

Definition at line 123 of file MRJConsole.h.

Definition at line 115 of file MRJConsole.h.

Definition at line 112 of file MRJConsole.h.

Definition at line 109 of file MRJConsole.h.

Definition at line 107 of file MRJConsole.h.

Definition at line 117 of file MRJConsole.h.

Definition at line 120 of file MRJConsole.h.

Definition at line 108 of file MRJConsole.h.

Definition at line 114 of file MRJConsole.h.

Definition at line 116 of file MRJConsole.h.

static const InterfaceInfo MRJConsole::sInterfaces [static, private]
Initial value:

Definition at line 126 of file MRJConsole.h.


The documentation for this class was generated from the following files: