1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /* ***** BEGIN LICENSE BLOCK *****
3 * Version: MPL 1.1/GPL 2.0/LGPL 2.1
5 * The contents of this file are subject to the Mozilla Public License Version
6 * 1.1 (the "License"); you may not use this file except in compliance with
7 * the License. You may obtain a copy of the License at
8 * http://www.mozilla.org/MPL/
10 * Software distributed under the License is distributed on an "AS IS" basis,
11 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
12 * for the specific language governing rights and limitations under the
15 * The Original Code is mozilla.org code.
17 * The Initial Developer of the Original Code is
18 * Netscape Communications Corporation.
19 * Portions created by the Initial Developer are Copyright (C) 1998
20 * the Initial Developer. All Rights Reserved.
24 * Alternatively, the contents of this file may be used under the terms of
25 * either the GNU General Public License Version 2 or later (the "GPL"), or
26 * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
27 * in which case the provisions of the GPL or the LGPL are applicable instead
28 * of those above. If you wish to allow use of your version of this file only
29 * under the terms of either the GPL or the LGPL, and not to allow others to
30 * use your version of this file under the terms of the MPL, indicate your
31 * decision by deleting the provisions above and replace them with the notice
32 * and other provisions required by the GPL or the LGPL. If you do not delete
33 * the provisions above, a recipient may use your version of this file under
34 * the terms of any one of the MPL, the GPL or the LGPL.
36 * ***** END LICENSE BLOCK ***** */
40 #include "npfunctions.h"
45 nsPluginThread
* thePluginThread
= NULL
;
47 NPError
NPP_New(NPMIMEType aType
,
55 dbgOut1("wrapper: NPP_New");
57 NPError rv
= NPERR_NO_ERROR
;
59 // lamely assuming there is only one embed tag on the page!
61 // if it is first time in, we don't have it yet
62 // initiate a thread with plugin running in it
63 thePluginThread
= new nsPluginThread((DWORD
)aType
);
66 return NPERR_GENERIC_ERROR
;
68 rv
= (NPError
)thePluginThread
->callNPP(action_npp_new
,
80 NPError
NPP_Destroy (NPP aInstance
, NPSavedData
** aSave
)
82 dbgOut1("wrapper: NPP_Destroy");
85 return NPERR_GENERIC_ERROR
;
87 NPError ret
= (NPError
)thePluginThread
->callNPP(action_npp_destroy
, (DWORD
)aInstance
, (DWORD
)aSave
);
89 delete thePluginThread
;
90 thePluginThread
= NULL
;
95 NPError
NPP_SetWindow (NPP aInstance
, NPWindow
* aNPWindow
)
97 dbgOut1("wrapper: NPP_SetWindow");
99 NPError rv
= (NPError
)thePluginThread
->callNPP(action_npp_set_window
, (DWORD
)aInstance
, (DWORD
)aNPWindow
);
103 NPError
NPP_NewStream(NPP aInstance
,
109 dbgOut1("wrapper: NPP_NewStream");
111 NPError rv
= (NPError
)thePluginThread
->callNPP(action_npp_new_stream
, (DWORD
)aInstance
, (DWORD
)aType
, (DWORD
)aStream
, (DWORD
)aSeekable
, (DWORD
)aStype
);
115 int32
NPP_WriteReady (NPP aInstance
, NPStream
*aStream
)
117 dbgOut1("wrapper: NPP_WriteReady");
119 int32 rv
= (int32
)thePluginThread
->callNPP(action_npp_write_ready
, (DWORD
)aInstance
, (DWORD
)aStream
);
123 int32
NPP_Write (NPP aInstance
, NPStream
*aStream
, int32 aOffset
, int32 len
, void *aBuffer
)
125 dbgOut1("wrapper: NPP_Write");
127 int32 rv
= (int32
)thePluginThread
->callNPP(action_npp_write
, (DWORD
)aInstance
, (DWORD
)aStream
, (DWORD
)aOffset
, (DWORD
)len
, (DWORD
)aBuffer
);
131 NPError
NPP_DestroyStream (NPP aInstance
, NPStream
*aStream
, NPError aReason
)
133 dbgOut1("wrapper: NPP_DestroyStream");
135 NPError rv
= (NPError
)thePluginThread
->callNPP(action_npp_destroy_stream
, (DWORD
)aInstance
, (DWORD
)aStream
, (DWORD
)aReason
);
139 void NPP_StreamAsFile (NPP aInstance
, NPStream
* aStream
, const char* aName
)
141 dbgOut1("wrapper: NPP_StreamAsFile");
143 thePluginThread
->callNPP(action_npp_stream_as_file
, (DWORD
)aInstance
, (DWORD
)aStream
, (DWORD
)aName
);
146 void NPP_Print (NPP aInstance
, NPPrint
* aPrintInfo
)
148 dbgOut1("wrapper: NPP_Print");
150 thePluginThread
->callNPP(action_npp_print
, (DWORD
)aInstance
, (DWORD
)aPrintInfo
);
153 void NPP_URLNotify(NPP aInstance
, const char* aUrl
, NPReason aReason
, void* aNotifyData
)
155 dbgOut1("wrapper: NPP_URLNotify");
157 thePluginThread
->callNPP(action_npp_url_notify
, (DWORD
)aInstance
, (DWORD
)aUrl
, (DWORD
)aReason
, (DWORD
)aNotifyData
);
160 NPError
NPP_GetValue(NPP aInstance
, NPPVariable aVariable
, void *aValue
)
162 dbgOut1("wrapper: NPP_GetValue");
164 NPError rv
= (NPError
)thePluginThread
->callNPP(action_npp_get_value
, (DWORD
)aInstance
, (DWORD
)aVariable
, (DWORD
)aValue
);
168 NPError
NPP_SetValue(NPP aInstance
, NPNVariable aVariable
, void *aValue
)
170 dbgOut1("wrapper: NPP_SetValue");
172 NPError rv
= (NPError
)thePluginThread
->callNPP(action_npp_set_value
, (DWORD
)aInstance
, (DWORD
)aVariable
, (DWORD
)aValue
);
176 int16
NPP_HandleEvent(NPP aInstance
, void* aEvent
)
178 dbgOut1("wrapper: NPP_HandleEvent");
180 int16 rv
= (int16
)thePluginThread
->callNPP(action_npp_handle_event
, (DWORD
)aInstance
, (DWORD
)aEvent
);