1 /*************************************************************************
3 Source Code Control System - Header
5 $Header: /zpool/svn/migration/cvs_rep_09_09_08/code/extensions/source/plugin/unx/npnapi.cxx,v 1.11 2008-01-14 14:53:25 ihi Exp $
7 *************************************************************************/
9 // MARKER(update_precomp.py): autogen include statement, do not remove
10 #include "precompiled_extensions.hxx"
11 #include <plugin/unx/plugcon.hxx>
16 #include <osl/module.h>
18 extern PluginConnector
* pConnector
;
19 extern XtAppContext app_context
;
20 extern int wakeup_fd
[];
21 extern Widget topLevel
, topBox
;
22 extern Display
* pAppDisplay
;
23 extern Display
* pXtAppDisplay
;
24 extern int nAppArguments
;
25 extern char** pAppArguments
;
27 void* CreateNewShell( void**, XLIB_Window
);
29 // begin Netscape plugin api calls
32 static void* l_NPN_MemAlloc( uint32 nBytes
)
34 void* pMem
= new char[nBytes
];
38 static void l_NPN_MemFree( void* pMem
)
40 delete [] (char*)pMem
;
43 static uint32
l_NPN_MemFlush( uint32
/*nSize*/ )
48 static NPError
l_NPN_DestroyStream( NPP instance
, NPStream
* stream
, NPError reason
)
50 UINT32 nInstance
= pConnector
->GetNPPID( instance
);
51 if( nInstance
== PluginConnector::UnknownNPPID
)
52 return NPERR_GENERIC_ERROR
;
54 UINT32 nFileID
= pConnector
->GetStreamID( stream
);
55 MediatorMessage
* pMes
=
57 Transact( eNPN_DestroyStream
,
58 &nInstance
, sizeof( nInstance
),
59 &nFileID
, sizeof( nFileID
),
60 POST_STRING( stream
->url
),
61 &reason
, sizeof( reason
),
65 return NPERR_GENERIC_ERROR
;
67 for( std::vector
< NPStream
* >::iterator it
= pConnector
->getStreamList().begin();
68 it
!= pConnector
->getStreamList().end(); ++it
)
72 pConnector
->getStreamList().erase( it
);
76 delete [] stream
->url
;
79 NPError aRet
= pConnector
->GetNPError( pMes
);
85 static JRIEnv
* l_NPN_GetJavaEnv()
87 // no java in this program
88 medDebug( 1, "SNI: NPN_GetJavaEnv\n" );
92 static jref
l_NPN_GetJavaPeer( NPP
/*instance*/ )
94 medDebug( 1, "SNI: NPN_GetJavaPeer\n" );
99 static NPError
l_NPN_GetURL( NPP instance
, const char* url
, const char* window
)
101 UINT32 nInstance
= pConnector
->GetNPPID( instance
);
102 if( nInstance
== PluginConnector::UnknownNPPID
)
103 return NPERR_GENERIC_ERROR
;
105 MediatorMessage
* pMes
=
107 Transact( eNPN_GetURL
,
108 &nInstance
, sizeof( nInstance
),
112 medDebug( !pMes
, "geturl: message unaswered\n" );
114 return NPERR_GENERIC_ERROR
;
117 NPError aRet
= pConnector
->GetNPError( pMes
);
118 medDebug( aRet
, "geturl returns %d\n", (int)aRet
);
123 static NPError
l_NPN_GetURLNotify( NPP instance
, const char* url
, const char* target
,
126 UINT32 nInstance
= pConnector
->GetNPPID( instance
);
127 if( nInstance
== PluginConnector::UnknownNPPID
)
128 return NPERR_GENERIC_ERROR
;
130 MediatorMessage
* pMes
=
132 Transact( eNPN_GetURLNotify
,
133 &nInstance
, sizeof( nInstance
),
136 ¬ifyData
, sizeof( void* ), // transmit the actual pointer
137 // since it is a pointer to private data fed back
138 // by NPP_URLNotify; this can be thought of as an ID
141 return NPERR_GENERIC_ERROR
;
144 NPError aRet
= pConnector
->GetNPError( pMes
);
149 static NPError
l_NPN_NewStream( NPP instance
, NPMIMEType type
, const char* target
,
151 // stream is a return value
153 UINT32 nInstance
= pConnector
->GetNPPID( instance
);
154 if( nInstance
== PluginConnector::UnknownNPPID
)
155 return NPERR_GENERIC_ERROR
;
157 MediatorMessage
* pMes
=
159 Transact( eNPN_NewStream
,
160 &nInstance
, sizeof( nInstance
),
165 return NPERR_GENERIC_ERROR
;
167 // returns a new NPStream and an error
168 NPError aRet
= pConnector
->GetNPError( pMes
);
171 NPStream
* pStream
= new NPStream
;
172 pStream
->url
= pMes
->GetString();
173 pStream
->end
= pMes
->GetUINT32();
174 pStream
->lastmodified
= pMes
->GetUINT32();
175 pStream
->ndata
= pStream
->pdata
= pStream
->notifyData
= NULL
;
177 pConnector
->getStreamList().push_back( pStream
);
185 static NPError
l_NPN_PostURLNotify( NPP instance
, const char* url
, const char* target
, uint32 len
, const char* buf
, NPBool file
, void* notifyData
)
187 UINT32 nInstance
= pConnector
->GetNPPID( instance
);
188 if( nInstance
== PluginConnector::UnknownNPPID
)
189 return NPERR_GENERIC_ERROR
;
191 MediatorMessage
* pMes
= pConnector
->
192 Transact( eNPN_PostURLNotify
,
193 &nInstance
, sizeof( nInstance
),
195 POST_STRING( target
),
198 &file
, sizeof( NPBool
),
199 ¬ifyData
, sizeof( void* ), // send the real pointer
203 return NPERR_GENERIC_ERROR
;
205 NPError aRet
= pConnector
->GetNPError( pMes
);
210 static NPError
l_NPN_PostURL( NPP instance
, const char* url
, const char* window
, uint32 len
, const char* buf
, NPBool file
)
212 UINT32 nInstance
= pConnector
->GetNPPID( instance
);
213 if( nInstance
== PluginConnector::UnknownNPPID
)
214 return NPERR_GENERIC_ERROR
;
216 MediatorMessage
* pMes
= pConnector
->
217 Transact( eNPN_PostURL
,
218 &nInstance
, sizeof( nInstance
),
220 POST_STRING( window
),
223 &file
, sizeof( NPBool
),
226 return NPERR_GENERIC_ERROR
;
228 NPError aRet
= pConnector
->GetNPError( pMes
);
233 static NPError
l_NPN_RequestRead( NPStream
* stream
, NPByteRange
* rangeList
)
235 medDebug( 1, "pluginapp: NPN_RequestRead\n" );
237 NPByteRange
* pRange
= rangeList
;
242 pRange
= pRange
->next
;
245 UINT32
* pArray
= new UINT32
[ 2 * nRanges
];
250 pArray
[ 2*n
] = (UINT32
)pRange
->offset
;
251 pArray
[ 2*n
+ 1] = (UINT32
)pRange
->length
;
253 pRange
= pRange
->next
;
255 UINT32 nFileID
= pConnector
->GetStreamID( stream
);
256 MediatorMessage
* pMes
= pConnector
->
257 Transact( eNPN_RequestRead
,
258 &nFileID
, sizeof( nFileID
),
259 &nRanges
, sizeof( nRanges
),
260 pArray
, sizeof( UINT32
) * 2 * nRanges
,
264 return NPERR_GENERIC_ERROR
;
266 NPError aRet
= pConnector
->GetNPError( pMes
);
272 static void l_NPN_Status( NPP instance
, const char* message
)
274 UINT32 nInstance
= pConnector
->GetNPPID( instance
);
275 if( nInstance
== PluginConnector::UnknownNPPID
)
278 pConnector
->Send( eNPN_Status
,
279 &nInstance
, sizeof( nInstance
),
280 POST_STRING( message
),
284 static const char* l_NPN_UserAgent( NPP instance
)
286 static char* pAgent
= NULL
;
288 UINT32 nInstance
= pConnector
->GetNPPID( instance
);
289 if( nInstance
== PluginConnector::UnknownNPPID
)
292 return "Mozilla 3.0";
293 else // e.g. flashplayer calls NPN_UserAgent with NULL
297 MediatorMessage
* pMes
= pConnector
->
298 Transact( eNPN_UserAgent
,
299 &nInstance
, sizeof( nInstance
),
307 pAgent
= pMes
->GetString();
311 medDebug( 1, "NPN_UserAgent returns %s\n", pAgent
);
317 static void l_NPN_Version( int* major
, int* minor
, int* net_major
, int* net_minor
)
319 MediatorMessage
* pMes
= pConnector
->
320 Transact( eNPN_Version
,
326 *major
= pMes
->GetUINT32();
327 *minor
= pMes
->GetUINT32();
328 *net_major
= pMes
->GetUINT32();
329 *net_minor
= pMes
->GetUINT32();
331 medDebug( 1, "pluginapp: NPN_Version: results %d %d, %d %d\n", *major
, *minor
, *net_major
, *net_minor
);
337 static int32
l_NPN_Write( NPP instance
, NPStream
* stream
, int32 len
, void* buffer
)
339 UINT32 nFileID
= pConnector
->GetStreamID( stream
);
340 if( nFileID
== PluginConnector::UnknownStreamID
)
341 return NPERR_GENERIC_ERROR
;
342 UINT32 nInstance
= pConnector
->GetNPPID( instance
);
343 if( nInstance
== PluginConnector::UnknownNPPID
)
344 return NPERR_GENERIC_ERROR
;
346 MediatorMessage
* pMes
= pConnector
->
347 Transact( eNPN_Write
,
348 &nInstance
, sizeof( nInstance
),
349 &nFileID
, sizeof( nFileID
),
357 INT32 nRet
= pMes
->GetUINT32();
361 static void l_NPN_ReloadPlugins( NPBool
/*reloadPages*/ )
363 medDebug( 1, "NPN_ReloadPlugins: SNI\n" );
366 static NPError
l_NPN_GetValue( NPP
, NPNVariable variable
, void* value
)
369 * We want to handle values injected into a NPNVariable which aren't in
370 * the old enum we build against, but that we know are in the new enum
373 switch( (int)variable
)
376 *((Display
**)value
) = pXtAppDisplay
;
377 medDebug( 1, "Display requested\n" );
379 case NPNVxtAppContext
:
380 *((XtAppContext
*)value
) = app_context
;
381 medDebug( 1, "AppContext requested\n" );
383 case NPNVjavascriptEnabledBool
:
385 *(NPBool
*)value
= false;
386 medDebug( 1, "javascript enabled requested\n" );
388 case NPNVasdEnabledBool
:
390 *(NPBool
*)value
= false;
391 medDebug( 1, "smart update enabled requested\n" );
393 case NPNVisOfflineBool
:
394 // no offline browsing
395 *(NPBool
*)value
= false;
396 medDebug( 1, "offline browsing requested\n" );
398 case NPNVSupportsXEmbedBool
:
401 medDebug( 1, "xembed requested\n" );
405 *(int*)value
= NPNVGtk2
;
409 medDebug( 1, "toolkit requested\n" );
412 medDebug( 1, "unknown NPNVariable %x requested\n", variable
);
413 return NPERR_INVALID_PARAM
;
415 return NPERR_NO_ERROR
;
418 static NPError
l_NPN_SetValue(NPP
/*instance*/, NPPVariable variable
, void *value
)
420 medDebug( 1, "NPN_SetValue %d=%p\n", variable
, value
);
424 static void l_NPN_InvalidateRect(NPP
/*instance*/, NPRect
* /*invalidRect*/)
426 medDebug( 1, "NPN_InvalidateRect\n" );
429 static void l_NPN_InvalidateRegion(NPP
/*instance*/, NPRegion
/*invalidRegion*/)
431 medDebug( 1, "NPN_InvalidateRegion\n" );
434 static void l_NPN_ForceRedraw(NPP
/*instance*/)
436 medDebug( 1, "NPN_ForceRedraw\n" );
441 static NPNetscapeFuncs aNetscapeFuncs
=
443 sizeof(aNetscapeFuncs
),
444 (NP_VERSION_MAJOR
<< 8) | NP_VERSION_MINOR
,
468 l_NPN_InvalidateRect
,
469 l_NPN_InvalidateRegion
,
473 static NPPluginFuncs aPluginFuncs
=
475 sizeof(aPluginFuncs
),
476 (NP_VERSION_MAJOR
<< 8) | NP_VERSION_MINOR
,
494 oslModule pPluginLib
= NULL
;
495 char*(*pNPP_GetMIMEDescription
)() = NULL
;
496 NPError (*pNP_Initialize
)(NPNetscapeFuncs
*,NPPluginFuncs
*) = NULL
;
497 NPError (*pNP_Shutdown
)() = NULL
;
499 std::vector
< PluginConnector
* > PluginConnector::allConnectors
;
501 PluginConnector::PluginConnector( int nSocket
) :
504 SetNewMessageHdl( LINK( this, PluginConnector
, NewMessageHdl
) );
507 PluginConnector::~PluginConnector()
511 IMPL_LINK( PluginConnector
, WorkOnNewMessageHdl
, Mediator
*, /*pMediator*/ )
513 MediatorMessage
* pMessage
;
514 CommandAtoms nCommand
;
515 while( (pMessage
= GetNextMessage( FALSE
)) )
517 nCommand
= (CommandAtoms
)pMessage
->GetUINT32();
518 medDebug( 1, "pluginapp: %s\n", GetCommandName( nCommand
) );
521 case eNPP_DestroyStream
:
523 UINT32 nInstance
= pMessage
->GetUINT32();
524 NPP instance
= m_aInstances
[ nInstance
]->instance
;
525 UINT32 nFileID
= pMessage
->GetUINT32();
526 NPStream
* pStream
= m_aNPWrapStreams
[ nFileID
];
527 NPError aReason
= GetNPError( pMessage
);
528 m_aNPWrapStreams
.erase( m_aNPWrapStreams
.begin() + nFileID
);
530 aReason
= aPluginFuncs
.destroystream( instance
, pStream
, aReason
);
531 Respond( pMessage
->m_nID
,
532 (char*)&aReason
, sizeof( aReason
),
535 delete [] pStream
->url
;
541 UINT32 nInstance
= pMessage
->GetUINT32();
542 ConnectorInstance
* pInst
= m_aInstances
[ nInstance
];
544 // some plugin rely on old netscapes behaviour
545 // to first destroy the widget and then destroy
546 // the instance, so mimic that behaviour here
548 XtDestroyWidget( (Widget
)pInst
->pShell
);
550 pInst
->pWidget
= pInst
->pShell
= NULL
;
552 // the other side will call eNPP_DestroyPhase2 after this
553 NPError aReason
= NPERR_NO_ERROR
;
554 Respond( pMessage
->m_nID
, (char*)&aReason
, sizeof( aReason
), NULL
);
557 case eNPP_DestroyPhase2
:
559 // now really destroy the instance
560 UINT32 nInstance
= pMessage
->GetUINT32();
561 ConnectorInstance
* pInst
= m_aInstances
[ nInstance
];
562 NPP instance
= pInst
->instance
;
563 NPSavedData
* pSave
= NULL
;
565 NPError aRet
= aPluginFuncs
.destroy( instance
, &pSave
);
568 Respond( pMessage
->m_nID
,
569 (char*)&aRet
, sizeof( aRet
),
570 pSave
->buf
, pSave
->len
,
572 delete [] (char*)pSave
->buf
;
575 Respond( pMessage
->m_nID
,
576 (char*)&aRet
, sizeof( aRet
),
581 if( pInst
->pGtkWindow
)
582 g_object_unref( G_OBJECT(pInst
->pGtkWindow
) );
583 if( pInst
->pGtkWidget
)
584 g_object_unref( G_OBJECT(pInst
->pGtkWidget
) );
587 m_aInstances
.erase( m_aInstances
.begin() + nInstance
);
590 medDebug( 1, "destroyed instance (returning %d)\n", aRet
);
595 UINT32 nInstance
= pMessage
->GetUINT32();
596 NPP instance
= m_aInstances
[ nInstance
]->instance
;
597 char* pType
= pMessage
->GetString();
598 NPStream
* pStream
= new NPStream
;
599 pStream
->url
= pMessage
->GetString();
600 pStream
->end
= pMessage
->GetUINT32();
601 pStream
->lastmodified
= pMessage
->GetUINT32();
602 pStream
->pdata
= pStream
->ndata
= pStream
->notifyData
= NULL
;
603 NPBool
* pSeekable
= (NPBool
*)pMessage
->GetBytes();
604 m_aNPWrapStreams
.push_back( pStream
);
605 uint16 nStype
= NP_ASFILE
;
606 NPError aRet
= aPluginFuncs
.newstream( instance
, pType
, pStream
,
607 *pSeekable
, &nStype
);
608 medDebug( 1, "pluginapp: NPP_NewStream( %p, %s, %p, %s, %p ) returns %d\n"
609 "stream = { pdata = %p, ndata = %p, url = %s, end = %d, lastmodified = %d, notifyData = %p }\n",
610 instance
, pType
, pStream
, *pSeekable
? "seekable" : "not seekable", &nStype
, (int)aRet
,
611 pStream
->pdata
, pStream
->ndata
, pStream
->url
, pStream
->end
, pStream
->lastmodified
, pStream
->notifyData
);
612 Respond( pMessage
->m_nID
,
613 (char*)&aRet
, sizeof( aRet
),
614 &nStype
, sizeof( nStype
),
622 char* pType
= pMessage
->GetString();
623 uint16
* pMode
= (uint16
*)pMessage
->GetBytes();
624 int16
* pArgc
= (int16
*)pMessage
->GetBytes();
625 NPP instance
= new NPP_t
;
626 instance
->pdata
= instance
->ndata
= NULL
;
627 ULONG nArgnBytes
, nArgvBytes
;
628 char* pArgn
= (char*)pMessage
->GetBytes( nArgnBytes
);
629 char* pArgv
= (char*)pMessage
->GetBytes( nArgvBytes
);
631 char* pSavedData
= (char*)pMessage
->GetBytes( nSaveBytes
);
632 ConnectorInstance
* pInst
=
633 new ConnectorInstance( instance
, pType
,
637 pSavedData
, nSaveBytes
);
638 m_aInstances
.push_back( pInst
);
640 aRet
= aPluginFuncs
.newp( pInst
->pMimeType
, instance
, *pMode
, *pArgc
,
641 pInst
->nArg
? pInst
->argn
: NULL
,
642 pInst
->nArg
? pInst
->argv
: NULL
,
643 ( nSaveBytes
== 4 && *(UINT32
*)pSavedData
== 0 ) ?
644 &(pInst
->aData
) : NULL
);
645 medDebug( 1, "pluginapp: NPP_New( %s, %p, %d, %d, %p, %p, %p ) returns %d\n",
647 instance
, *pMode
, pInst
->nArg
, pInst
->argn
, pInst
->argv
, &pInst
->aData
,
649 #if OSL_DEBUG_LEVEL > 1
650 for( int i
= 0; i
< pInst
->nArg
; i
++ )
651 medDebug( 1, " \"%s\"=\"%s\"\n", pInst
->argn
[i
], pInst
->argv
[i
] );
655 // check if XEMBED is to be used
656 // ask for Bool. there seems to be no clear definition whether the
657 // return value should be an int or unsigned char
658 // int can hold both and will be nonzero in case of "true"
659 if( aPluginFuncs
.getvalue
)
661 int bNeedsXEmbed
= 0;
662 NPError error
= aPluginFuncs
.getvalue( instance
, NPPVpluginNeedsXEmbed
, (void *)&bNeedsXEmbed
);
663 if( error
== NPERR_NO_ERROR
)
664 pInst
->bShouldUseXEmbed
= (bNeedsXEmbed
!= 0);
665 medDebug( 1, "should use xembed = %s\n", pInst
->bShouldUseXEmbed
? "true" : "false" );
669 Respond( pMessage
->m_nID
,
670 (char*)&aRet
, sizeof( aRet
),
679 UINT32 nInstance
= pMessage
->GetUINT32();
680 ConnectorInstance
* pInst
= m_aInstances
[ nInstance
];
681 NPWindow
* pWindow
= (NPWindow
*)pMessage
->GetBytes();
683 if( pWindow
->width
< 1 )
685 if( pWindow
->height
< 1 )
689 if( pInst
->bShouldUseXEmbed
)
691 if( ! pInst
->pGtkWidget
)
693 medDebug( 1, "creating gtk plug and socket\n" );
695 pInst
->pGtkWindow
= gtk_plug_new((GdkNativeWindow
)reinterpret_cast<sal_uIntPtr
>(pWindow
->window
));
696 gtk_widget_show( pInst
->pGtkWindow
);
697 pInst
->pGtkWidget
= gtk_socket_new();
698 gtk_widget_show( pInst
->pGtkWidget
);
699 gtk_container_add( GTK_CONTAINER(pInst
->pGtkWindow
), pInst
->pGtkWidget
);
700 gtk_widget_show_all( pInst
->pGtkWindow
);
701 pInst
->window
.window
= (void *)gtk_socket_get_id( GTK_SOCKET(pInst
->pGtkWidget
) );
703 XSync( pAppDisplay
, False
);
705 XMapWindow( pAppDisplay
, GDK_WINDOW_XWINDOW(pInst
->pGtkWindow
->window
) );
707 XSync( pAppDisplay
, False
);
710 // update widget size; alas out parent is not yet really XEMBED conformant
711 gtk_widget_set_size_request( pInst
->pGtkWidget
, pWindow
->width
, pWindow
->height
);
712 gtk_window_resize( GTK_WINDOW(pInst
->pGtkWindow
), pWindow
->width
, pWindow
->height
);
714 GdkScreen
* pGdkScreen
= gtk_widget_get_screen( pInst
->pGtkWidget
);
715 Screen
* pScreen
= ScreenOfDisplay( pAppDisplay
, gdk_screen_get_number( pGdkScreen
) );
719 pInst
->window
.width
= pWindow
->width
;
720 pInst
->window
.height
= pWindow
->height
;
721 pInst
->window
.clipRect
.left
= 0;
722 pInst
->window
.clipRect
.top
= 0;
723 pInst
->window
.clipRect
.right
= pWindow
->width
;
724 pInst
->window
.clipRect
.bottom
= pWindow
->height
;
725 pInst
->window
.ws_info
= &pInst
->ws_info
;
726 pInst
->window
.type
= NPWindowTypeWindow
;
727 pInst
->ws_info
.type
= NP_SETWINDOW
;
728 pInst
->ws_info
.display
= pAppDisplay
;
729 pInst
->ws_info
.visual
= DefaultVisualOfScreen( pScreen
);
730 pInst
->ws_info
.colormap
= DefaultColormapOfScreen( pScreen
);
731 pInst
->ws_info
.depth
= DefaultDepthOfScreen( pScreen
);
736 if( ! pInst
->pWidget
)
738 pInst
->pWidget
= CreateNewShell( &(pInst
->pShell
), (XLIB_Window
)pWindow
->window
);
741 // fill in NPWindow and NPCallbackStruct
742 pInst
->window
.window
= (void*)XtWindow( (Widget
)pInst
->pWidget
);
745 pInst
->window
.width
= pWindow
->width
;
746 pInst
->window
.height
= pWindow
->height
;
747 pInst
->window
.clipRect
.left
= 0;
748 pInst
->window
.clipRect
.top
= 0;
749 pInst
->window
.clipRect
.right
= pWindow
->width
;
750 pInst
->window
.clipRect
.bottom
= pWindow
->height
;
751 pInst
->window
.ws_info
= &pInst
->ws_info
;
752 pInst
->window
.type
= NPWindowTypeWindow
;
753 pInst
->ws_info
.type
= NP_SETWINDOW
;
754 pInst
->ws_info
.display
= XtDisplay( (Widget
)pInst
->pWidget
);
755 pInst
->ws_info
.visual
= DefaultVisualOfScreen( XtScreen( (Widget
)pInst
->pWidget
) );
756 pInst
->ws_info
.colormap
= DefaultColormapOfScreen( XtScreen( (Widget
)pInst
->pWidget
) );
757 pInst
->ws_info
.depth
= DefaultDepthOfScreen( XtScreen( (Widget
)pInst
->pWidget
) );
759 XtResizeWidget( (Widget
)pInst
->pShell
,
761 pInst
->window
.height
,
763 XtResizeWidget( (Widget
)pInst
->pWidget
,
765 pInst
->window
.height
,
769 NPError aRet
= aPluginFuncs
.setwindow( pInst
->instance
, &pInst
->window
);
770 medDebug( 1, "pluginapp: NPP_SetWindow returns %d\n", (int) aRet
);
771 Respond( pMessage
->m_nID
,
772 (char*)&aRet
, sizeof( aRet
),
774 delete [] (char*)pWindow
;
777 case eNPP_StreamAsFile
:
779 UINT32 nInstance
= pMessage
->GetUINT32();
780 NPP instance
= m_aInstances
[ nInstance
]->instance
;
781 UINT32 nFileID
= pMessage
->GetUINT32();
782 NPStream
* pStream
= m_aNPWrapStreams
[ nFileID
];
783 char* fname
= pMessage
->GetString();
784 medDebug( 1, "pluginapp: NPP_StreamAsFile %s\n", fname
);
785 aPluginFuncs
.asfile( instance
, pStream
, fname
);
791 UINT32 nInstance
= pMessage
->GetUINT32();
792 NPP instance
= m_aInstances
[ nInstance
]->instance
;
793 char* url
= pMessage
->GetString();
794 NPReason
* pReason
= (NPReason
*)pMessage
->GetBytes();
795 void** notifyData
= (void**)pMessage
->GetBytes();
796 aPluginFuncs
.urlnotify( instance
, url
, *pReason
, *notifyData
);
799 delete [] notifyData
;
802 case eNPP_WriteReady
:
804 UINT32 nInstance
= pMessage
->GetUINT32();
805 NPP instance
= m_aInstances
[ nInstance
]->instance
;
806 UINT32 nFileID
= pMessage
->GetUINT32();
807 NPStream
* pStream
= m_aNPWrapStreams
[ nFileID
];
808 int32 nRet
= aPluginFuncs
.writeready( instance
, pStream
);
810 medDebug( 1, "pluginapp: NPP_WriteReady( %p, %p ) (stream id = %d) returns %d\n",
811 instance
, pStream
, nFileID
, nRet
);
813 Respond( pMessage
->m_nID
,
814 (char*)&nRet
, sizeof( nRet
),
820 UINT32 nInstance
= pMessage
->GetUINT32();
821 NPP instance
= m_aInstances
[ nInstance
]->instance
;
822 UINT32 nFileID
= pMessage
->GetUINT32();
823 NPStream
* pStream
= m_aNPWrapStreams
[ nFileID
];
824 int32 offset
= pMessage
->GetUINT32();
826 char* buffer
= (char*)pMessage
->GetBytes( len
);
827 int32 nRet
= aPluginFuncs
.write( instance
, pStream
, offset
, len
, buffer
);
829 medDebug( 1,"pluginapp: NPP_Write( %p, %p, %d, %d, %p ) returns %d\n"
830 "stream = { pdata = %p, ndata = %p, url = %s, end = %d, lastmodified = %d, notifyData = %p }\n",
831 instance
, pStream
, offset
, len
, buffer
, nRet
,
832 pStream
->pdata
, pStream
->ndata
, pStream
->url
, pStream
->end
, pStream
->lastmodified
, pStream
->notifyData
);
834 Respond( pMessage
->m_nID
,
835 (char*)&nRet
, sizeof( nRet
),
840 case eNPP_GetMIMEDescription
:
842 if( ! pNPP_GetMIMEDescription
)
843 pNPP_GetMIMEDescription
= (char*(*)())
844 osl_getAsciiFunctionSymbol( pPluginLib
, "NPP_GetMIMEDescription" );
845 char* pMIME
= pNPP_GetMIMEDescription();
846 Respond( pMessage
->m_nID
,
847 POST_STRING( pMIME
),
851 case eNPP_Initialize
:
855 (NPError(*)(NPNetscapeFuncs
*, NPPluginFuncs
*))
856 osl_getAsciiFunctionSymbol( pPluginLib
, "NP_Initialize" );
857 medDebug( !pNP_Initialize
, "no NP_Initialize, %s\n", dlerror() );
858 pNP_Shutdown
= (NPError(*)())
859 osl_getAsciiFunctionSymbol( pPluginLib
, "NP_Shutdown" );
860 medDebug( !pNP_Initialize
, "no NP_Shutdown, %s\n", dlerror() );
862 medDebug( 1, "entering NP_Initialize\n" );
863 NPError aRet
= pNP_Initialize( &aNetscapeFuncs
, &aPluginFuncs
);
864 medDebug( 1, "pluginapp: NP_Initialize returns %d\n", (int) aRet
);
865 Respond( pMessage
->m_nID
, (char*)&aRet
, sizeof( aRet
), NULL
);
870 write( wakeup_fd
[1], "xxxx", 4 );
874 medDebug( 1, "caught unknown NPP request %d\n", nCommand
);
882 void LoadAdditionalLibs( const char* _pPluginLib
)
884 medDebug( 1, "LoadAdditionalLibs %s\n", _pPluginLib
);
886 if( ! strncmp( _pPluginLib
, "libflashplayer.so", 17 ) )
888 /* #b4951312# flash 7 implicitly assumes a gtk application
889 * if the API version is greater or equal to 12 (probably
890 * because they think they run in mozilla then). In that
891 * case they try to find gtk within the process and crash
892 * when they don't find it.
894 aNetscapeFuncs
.version
= 11;
895 aPluginFuncs
.version
= 11;