1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788
|
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* The contents of this file are subject to the Netscape Public License
* Version 1.0 (the "NPL"); you may not use this file except in
* compliance with the NPL. You may obtain a copy of the NPL at
* http://www.mozilla.org/NPL/
*
* Software distributed under the NPL is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
* for the specific language governing rights and limitations under the
* NPL.
*
* The Initial Developer of this code under the NPL is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
* Reserved.
*/
// TODO: Implement Java callbacks
#include "xp_core.h"
#include "nsplugin.h"
#include "ns4xPlugin.h"
#include "nsIPluginStream.h"
#include "ns4xPluginInstance.h"
////////////////////////////////////////////////////////////////////////
NPNetscapeFuncs ns4xPlugin::CALLBACKS;
nsIPluginManager * ns4xPlugin::mPluginManager;
nsIMalloc * ns4xPlugin::mMalloc;
void
ns4xPlugin::CheckClassInitialized(void)
{
static PRBool initialized = FALSE;
if (initialized)
return;
mPluginManager = nsnull;
mMalloc = nsnull;
// XXX It'd be nice to make this const and initialize it
// statically...
CALLBACKS.size = sizeof(CALLBACKS);
CALLBACKS.version = (NP_VERSION_MAJOR << 8) + NP_VERSION_MINOR;
CALLBACKS.geturl = NewNPN_GetURLProc(_geturl);
CALLBACKS.posturl = NewNPN_PostURLProc(_posturl);
CALLBACKS.requestread = NewNPN_RequestReadProc(_requestread);
CALLBACKS.newstream = NewNPN_NewStreamProc(_newstream);
CALLBACKS.write = NewNPN_WriteProc(_write);
CALLBACKS.destroystream = NewNPN_DestroyStreamProc(_destroystream);
CALLBACKS.status = NewNPN_StatusProc(_status);
CALLBACKS.uagent = NewNPN_UserAgentProc(_useragent);
CALLBACKS.memalloc = NewNPN_MemAllocProc(_memalloc);
CALLBACKS.memfree = NewNPN_MemFreeProc(_memfree);
CALLBACKS.memflush = NewNPN_MemFlushProc(_memflush);
CALLBACKS.reloadplugins = NewNPN_ReloadPluginsProc(_reloadplugins);
CALLBACKS.getJavaEnv = NewNPN_GetJavaEnvProc(_getJavaEnv);
// CALLBACKS.getJavaPeer = NewNPN_GetJavaPeerProc(_getJavaPeer);
CALLBACKS.geturlnotify = NewNPN_GetURLNotifyProc(_geturlnotify);
CALLBACKS.posturlnotify = NewNPN_PostURLNotifyProc(_posturlnotify);
CALLBACKS.getvalue = NewNPN_GetValueProc(_getvalue);
CALLBACKS.setvalue = NewNPN_SetValueProc(_setvalue);
CALLBACKS.invalidaterect = NewNPN_InvalidateRectProc(_invalidaterect);
CALLBACKS.invalidateregion = NewNPN_InvalidateRegionProc(_invalidateregion);
CALLBACKS.forceredraw = NewNPN_ForceRedrawProc(_forceredraw);
initialized = TRUE;
};
////////////////////////////////////////////////////////////////////////
ns4xPlugin::ns4xPlugin(NPPluginFuncs* callbacks, NP_PLUGINSHUTDOWN aShutdown)
{
NS_INIT_REFCNT();
memcpy((void*) &fCallbacks, (void*) callbacks, sizeof(fCallbacks));
fShutdownEntry = aShutdown;
}
ns4xPlugin::~ns4xPlugin(void)
{
}
////////////////////////////////////////////////////////////////////////
// nsISupports stuff
NS_IMPL_ADDREF(ns4xPlugin);
NS_IMPL_RELEASE(ns4xPlugin);
static NS_DEFINE_IID(kILiveConnectPluginIID, NS_ILIVECONNECTPLUGIN_IID);
static NS_DEFINE_IID(kIPluginIID, NS_IPLUGIN_IID);
static NS_DEFINE_IID(kIFactoryIID, NS_IFACTORY_IID);
static NS_DEFINE_IID(kISupportsIID, NS_ISUPPORTS_IID);
static NS_DEFINE_IID(kIWindowlessPluginInstancePeerIID, NS_IWINDOWLESSPLUGININSTANCEPEER_IID);
static NS_DEFINE_IID(kISeekablePluginStreamPeerIID, NS_ISEEKABLEPLUGINSTREAMPEER_IID);
nsresult
ns4xPlugin::QueryInterface(const nsIID& iid, void** instance)
{
if (instance == NULL)
return NS_ERROR_NULL_POINTER;
if (iid.Equals(kIPluginIID))
{
*instance = (void *)(nsIPlugin *)this;
AddRef();
return NS_OK;
}
if (iid.Equals(kILiveConnectPluginIID))
{
// Check the 4.x plugin callbacks to see if it supports
// LiveConnect...
if (fCallbacks.javaClass == NULL)
return NS_NOINTERFACE;
*instance = (void *)(nsILiveConnectPlugin *)this;
AddRef();
return NS_OK;
}
if (iid.Equals(kIFactoryIID))
{
*instance = (void *)(nsIFactory *)this;
AddRef();
return NS_OK;
}
if (iid.Equals(kISupportsIID))
{
*instance = (void *)(nsISupports *)this;
AddRef();
return NS_OK;
}
return NS_NOINTERFACE;
}
////////////////////////////////////////////////////////////////////////
// Static factory method.
//
nsresult
ns4xPlugin::CreatePlugin(PRLibrary *library,
nsIPlugin **result)
{
CheckClassInitialized();
NP_GETENTRYPOINTS pfnGetEntryPoints =
(NP_GETENTRYPOINTS)PR_FindSymbol(library, "NP_GetEntryPoints");
if (pfnGetEntryPoints == NULL)
return NS_ERROR_FAILURE;
NPPluginFuncs callbacks;
memset((void*) &callbacks, 0, sizeof(callbacks));
callbacks.size = sizeof(callbacks);
if (pfnGetEntryPoints(&callbacks) != NS_OK)
return NS_ERROR_FAILURE; // XXX
#ifdef XP_WIN // XXX This is really XP, but we need to figure out how to do HIBYTE()
if (HIBYTE(callbacks.version) < NP_VERSION_MAJOR)
return NS_ERROR_FAILURE;
#endif
NP_PLUGINSHUTDOWN pfnShutdown =
(NP_PLUGINSHUTDOWN)PR_FindSymbol(library, "NP_Shutdown");
// the NP_Initialize entry point was misnamed as NP_PluginInit,
// early in plugin project development. Its correct name is
// documented now, and new developers expect it to work. However,
// I don't want to break the plugins already in the field, so
// we'll accept either name
NP_PLUGININIT pfnInitialize =
(NP_PLUGININIT)PR_FindSymbol(library, "NP_Initialize");
if (!pfnInitialize) {
pfnInitialize =
(NP_PLUGININIT)PR_FindSymbol(library, "NP_PluginInit");
}
if (pfnInitialize == NULL)
return NS_ERROR_UNEXPECTED; // XXX Right error?
if (pfnInitialize(&ns4xPlugin::CALLBACKS) != NS_OK)
return NS_ERROR_UNEXPECTED; // XXX shoudl convert the 4.x error...
*result = new ns4xPlugin(&callbacks, pfnShutdown);
NS_ADDREF(*result);
if (*result == NULL)
return NS_ERROR_OUT_OF_MEMORY;
return NS_OK;
}
nsresult ns4xPlugin :: CreateInstance(nsISupports *aOuter,
const nsIID &aIID,
void **aResult)
{
if (aResult == NULL) {
return NS_ERROR_NULL_POINTER;
}
*aResult = NULL;
nsISupports *inst;
inst = nsnull;
inst = (nsISupports *)(nsIPluginInstance *)new ns4xPluginInstance(&fCallbacks);
if (inst == NULL) {
return NS_ERROR_OUT_OF_MEMORY;
}
nsresult res = inst->QueryInterface(aIID, aResult);
if (res != NS_OK) {
// We didn't get the right interface, so clean up
delete inst;
}
return res;
}
nsresult ns4xPlugin :: LockFactory(PRBool aLock)
{
// Not implemented in simplest case.
return NS_OK;
}
static NS_DEFINE_IID(kIPluginManagerIID, NS_IPLUGINMANAGER_IID);
static NS_DEFINE_IID(kIMallocIID, NS_IMALLOC_IID);
nsresult
ns4xPlugin::Initialize(nsISupports* browserInterfaces)
{
nsresult rv = NS_OK;
if (nsnull == mPluginManager)
rv = browserInterfaces->QueryInterface(kIPluginManagerIID, (void **)&mPluginManager);
if (nsnull == mMalloc)
rv = browserInterfaces->QueryInterface(kIMallocIID, (void **)&mMalloc);
return rv;
}
nsresult
ns4xPlugin::Shutdown(void)
{
if (nsnull != fShutdownEntry)
{
#ifdef NS_DEBUG
printf("shutting down plugin %08x\n", this);
#endif
fShutdownEntry();
fShutdownEntry = nsnull;
}
NS_IF_RELEASE(mPluginManager);
NS_IF_RELEASE(mMalloc);
return NS_OK;
}
nsresult
ns4xPlugin::GetMIMEDescription(const char* *resultingDesc)
{
printf("plugin getmimedescription called\n");
*resultingDesc = "";
return NS_OK; // XXX make a callback, etc.
}
nsresult
ns4xPlugin::GetValue(nsPluginVariable variable, void *value)
{
printf("plugin getvalue %d called\n", variable);
return NS_OK;
}
nsresult
ns4xPlugin::GetJavaClass(jclass *resultingClass)
{
*resultingClass = (jclass)fCallbacks.javaClass;
return NS_OK;
}
////////////////////////////////////////////////////////////////////////
//
// Static callbacks that get routed back through the new C++ API
//
nsresult NP_EXPORT
ns4xPlugin::_geturl(NPP npp, const char* relativeURL, const char* target)
{
nsIPluginInstance *inst = (nsIPluginInstance *) npp->ndata;
NS_ASSERTION(inst != NULL, "null instance");
NS_ASSERTION(mPluginManager != NULL, "null manager");
if (inst == NULL)
return NS_ERROR_UNEXPECTED; // XXX
return mPluginManager->GetURL(inst, relativeURL, target);
}
nsresult NP_EXPORT
ns4xPlugin::_geturlnotify(NPP npp, const char* relativeURL, const char* target,
void* notifyData)
{
nsIPluginInstance *inst = (nsIPluginInstance *) npp->ndata;
NS_ASSERTION(inst != NULL, "null instance");
NS_ASSERTION(mPluginManager != NULL, "null manager");
if (inst == NULL)
return NS_ERROR_UNEXPECTED; // XXX
return mPluginManager->GetURL(inst, relativeURL, target,
notifyData);
}
nsresult NP_EXPORT
ns4xPlugin::_posturlnotify(NPP npp, const char* relativeURL, const char *target,
uint32 len, const char *buf, NPBool file,
void* notifyData)
{
nsIPluginInstance *inst = (nsIPluginInstance *) npp->ndata;
NS_ASSERTION(inst != NULL, "null instance");
NS_ASSERTION(mPluginManager != NULL, "null manager");
if (inst == NULL)
return NS_ERROR_UNEXPECTED; // XXX
return mPluginManager->PostURL(inst, relativeURL, target,
len, buf, file, notifyData);
}
nsresult NP_EXPORT
ns4xPlugin::_posturl(NPP npp, const char* relativeURL, const char *target, uint32 len,
const char *buf, NPBool file)
{
nsIPluginInstance *inst = (nsIPluginInstance *) npp->ndata;
NS_ASSERTION(inst != NULL, "null instance");
NS_ASSERTION(mPluginManager != NULL, "null manager");
if (inst == NULL)
return NS_ERROR_UNEXPECTED; // XXX
return mPluginManager->PostURL(inst, relativeURL, target,
len, buf, file);
}
////////////////////////////////////////////////////////////////////////
/**
* A little helper class used to wrap up plugin manager streams (that is,
* streams from the plugin to the browser).
*/
class ns4xStreamWrapper
{
protected:
nsIOutputStream *fStream;
NPStream fNPStream;
public:
ns4xStreamWrapper(nsIOutputStream* stream);
~ns4xStreamWrapper();
nsIOutputStream*
GetStream(void);
NPStream*
GetNPStream(void) {
return &fNPStream;
};
};
ns4xStreamWrapper::ns4xStreamWrapper(nsIOutputStream* stream)
: fStream(stream)
{
NS_ASSERTION(stream != NULL, "bad stream");
NS_ADDREF(fStream);
memset(&fNPStream, 0, sizeof(fNPStream));
fNPStream.ndata = (void*) this;
}
ns4xStreamWrapper::~ns4xStreamWrapper(void)
{
NS_IF_RELEASE(fStream);
}
nsIOutputStream*
ns4xStreamWrapper::GetStream(void)
{
NS_IF_ADDREF(fStream);
return fStream;
}
////////////////////////////////////////////////////////////////////////
nsresult NP_EXPORT
ns4xPlugin::_newstream(NPP npp, NPMIMEType type, const char* window, NPStream* *result)
{
nsIPluginInstance *inst = (nsIPluginInstance *) npp->ndata;
NS_ASSERTION(inst != NULL, "null instance");
if (inst == NULL)
return NS_ERROR_UNEXPECTED; // XXX
nsresult error;
nsIOutputStream* stream;
nsIPluginInstancePeer *peer;
if (NS_OK == inst->GetPeer(&peer))
{
if ((error = peer->NewStream((const char*) type, window, &stream)) != NS_OK)
{
NS_RELEASE(peer);
return error;
}
ns4xStreamWrapper* wrapper = new ns4xStreamWrapper(stream);
if (wrapper == NULL)
{
NS_RELEASE(peer);
NS_RELEASE(stream);
return NS_ERROR_OUT_OF_MEMORY;
}
(*result) = wrapper->GetNPStream();
NS_RELEASE(peer);
return error;
}
else
return NS_ERROR_UNEXPECTED;
}
int32 NP_EXPORT
ns4xPlugin::_write(NPP npp, NPStream *pstream, int32 len, void *buffer)
{
ns4xStreamWrapper* wrapper = (ns4xStreamWrapper*) npp->ndata;
NS_ASSERTION(wrapper != NULL, "null wrapper");
if (wrapper == NULL)
return 0;
nsIOutputStream* stream = wrapper->GetStream();
PRInt32 count = 0;
nsresult rv = stream->Write((char *)buffer, 0, len, &count);
NS_RELEASE(stream);
return count;
}
nsresult NP_EXPORT
ns4xPlugin::_destroystream(NPP npp, NPStream *pstream, NPError reason)
{
ns4xStreamWrapper* wrapper = (ns4xStreamWrapper*) npp->ndata;
NS_ASSERTION(wrapper != NULL, "null wrapper");
if (wrapper == NULL)
return 0;
// This will release the wrapped nsIOutputStream.
delete wrapper;
return NS_OK;
}
void NP_EXPORT
ns4xPlugin::_status(NPP npp, const char *message)
{
nsIPluginInstance *inst = (nsIPluginInstance *) npp->ndata;
NS_ASSERTION(inst != NULL, "null instance");
if (inst == NULL)
return;
nsIPluginInstancePeer *peer;
if (NS_OK == inst->GetPeer(&peer))
{
peer->ShowStatus(message);
NS_RELEASE(peer);
}
}
void NP_EXPORT
ns4xPlugin::_memfree (void *ptr)
{
mMalloc->Free(ptr);
}
uint32 NP_EXPORT
ns4xPlugin::_memflush(uint32 size)
{
mMalloc->HeapMinimize();
return 0;
}
void NP_EXPORT
ns4xPlugin::_reloadplugins(NPBool reloadPages)
{
mPluginManager->ReloadPlugins(reloadPages);
}
void NP_EXPORT
ns4xPlugin::_invalidaterect(NPP npp, NPRect *invalidRect)
{
nsIPluginInstance *inst = (nsIPluginInstance *) npp->ndata;
NS_ASSERTION(inst != NULL, "null instance");
if (inst == NULL)
return;
nsIPluginInstancePeer *peer;
nsIWindowlessPluginInstancePeer *wpeer;
if (NS_OK == inst->GetPeer(&peer))
{
if (NS_OK == peer->QueryInterface(kIWindowlessPluginInstancePeerIID, (void **)&wpeer))
{
// XXX nsRect & NPRect are structurally equivalent
wpeer->InvalidateRect((nsPluginRect *)invalidRect);
NS_RELEASE(wpeer);
}
NS_RELEASE(peer);
}
}
void NP_EXPORT
ns4xPlugin::_invalidateregion(NPP npp, NPRegion invalidRegion)
{
nsIPluginInstance *inst = (nsIPluginInstance *) npp->ndata;
NS_ASSERTION(inst != NULL, "null instance");
if (inst == NULL)
return;
nsIPluginInstancePeer *peer;
nsIWindowlessPluginInstancePeer *wpeer;
if (NS_OK == inst->GetPeer(&peer))
{
if (NS_OK == peer->QueryInterface(kIWindowlessPluginInstancePeerIID, (void **)&wpeer))
{
// XXX nsRegion & NPRegion are typedef'd to the same thing
wpeer->InvalidateRegion((nsPluginRegion)invalidRegion);
NS_RELEASE(wpeer);
}
NS_RELEASE(peer);
}
}
void NP_EXPORT
ns4xPlugin::_forceredraw(NPP npp)
{
nsIPluginInstance *inst = (nsIPluginInstance *) npp->ndata;
NS_ASSERTION(inst != NULL, "null instance");
if (inst == NULL)
return;
nsIPluginInstancePeer *peer;
nsIWindowlessPluginInstancePeer *wpeer;
if (NS_OK == inst->GetPeer(&peer))
{
if (NS_OK == peer->QueryInterface(kIWindowlessPluginInstancePeerIID, (void **)&wpeer))
{
wpeer->ForceRedraw();
NS_RELEASE(wpeer);
}
NS_RELEASE(peer);
}
}
nsresult NP_EXPORT
ns4xPlugin::_getvalue(NPP npp, NPNVariable variable, void *result)
{
nsIPluginInstance *inst = (nsIPluginInstance *) npp->ndata;
NS_ASSERTION(inst != NULL, "null instance");
if (inst == NULL)
return NS_ERROR_FAILURE; // XXX
nsIPluginInstancePeer *peer;
if (NS_OK == inst->GetPeer(&peer))
{
nsresult rv;
// XXX Note that for backwards compatibility, the old NPNVariables
// map correctly to NPPluginManagerVariables.
rv = peer->GetValue((nsPluginInstancePeerVariable)variable, result);
NS_RELEASE(peer);
return rv;
}
else
return NS_ERROR_UNEXPECTED;
}
nsresult NP_EXPORT
ns4xPlugin::_setvalue(NPP npp, NPPVariable variable, void *result)
{
ns4xPluginInstance *inst = (ns4xPluginInstance *) npp->ndata;
NS_ASSERTION(inst != NULL, "null instance");
if (inst == NULL)
return NS_ERROR_FAILURE; // XXX
switch (variable)
{
case NPPVpluginWindowBool:
return inst->SetWindowless(*((NPBool *)result));
case NPPVpluginTransparentBool:
return inst->SetTransparent(*((NPBool *)result));
default:
return NS_OK;
}
#if 0
nsIPluginInstancePeer *peer;
if (NS_OK == inst->GetPeer(&peer))
{
nsresult rv;
// XXX Note that for backwards compatibility, the old NPPVariables
// map correctly to NPPluginVariables.
rv = peer->SetValue((nsPluginInstancePeerVariable)variable, result);
NS_RELEASE(peer);
return rv;
}
else
return NS_ERROR_UNEXPECTED;
#endif
}
nsresult NP_EXPORT
ns4xPlugin::_requestread(NPStream *pstream, NPByteRange *rangeList)
{
nsIPluginStreamPeer* streamPeer = (nsIPluginStreamPeer*) pstream->ndata;
NS_ASSERTION(streamPeer != NULL, "null streampeer");
if (streamPeer == NULL)
return NS_ERROR_FAILURE; // XXX
nsISeekablePluginStreamPeer* seekablePeer = NULL;
if (streamPeer->QueryInterface(kISeekablePluginStreamPeerIID,
(void**)seekablePeer) == NS_OK)
{
nsresult error;
// XXX nsByteRange & NPByteRange are structurally equivalent.
error = seekablePeer->RequestRead((nsByteRange *)rangeList);
NS_RELEASE(seekablePeer);
return error;
}
return NS_ERROR_UNEXPECTED;
}
////////////////////////////////////////////////////////////////////////
//
// On 68K Mac (XXX still supported?), we need to make sure that the
// pointers are in D0 for the following functions that return pointers.
//
#if defined(XP_MAC) && !defined(powerc)
#pragma pointers_in_D0
#endif
JRIEnv* NP_EXPORT
ns4xPlugin::_getJavaEnv(void)
{
return NULL;
}
const char * NP_EXPORT
ns4xPlugin::_useragent(NPP npp)
{
NS_ASSERTION(mPluginManager != NULL, "null pluginmanager");
if (mPluginManager == NULL)
return NULL;
char *retstr;
mPluginManager->UserAgent((const char **)&retstr);
return retstr;
}
void * NP_EXPORT
ns4xPlugin::_memalloc (uint32 size)
{
return mMalloc->Alloc(size);
}
#if 0
#ifdef JAVA
java_lang_Class* NP_EXPORT
ns4xPlugin::_getJavaClass(void* handle)
{
// Is this just a generic call into the Java VM?
return NULL;
}
#endif
jref NP_EXPORT
ns4xPlugin::_getJavaPeer(NPP npp)
{
NPIPluginInstancePeer* peer = (NPIPluginInstancePeer*) npp->ndata;
PR_ASSERT(peer != NULL);
if (peer == NULL)
return NULL;
static NS_DEFINE_IID(kILiveConnectPluginInstancePeerIID,
NP_ILIVECONNECTPLUGININSTANCEPEER_IID);
NPILiveConnectPluginInstancePeer* lcPeer = NULL;
if (peer->QueryInterface(kILiveConnectPluginInstancePeerIID,
(void**) &lcPeer) == NS_OK) {
jobject result = lcPeer->GetJavaPeer();
lcPeer->Release();
return result;
}
return NULL;
}
#endif
#if defined(XP_MAC) && !defined(powerc)
#pragma pointers_in_A0
#endif
//
////////////////////////////////////////////////////////////////////////
|