Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /*************************************************************************
3 : *
4 : * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 : *
6 : * Copyright 2000, 2010 Oracle and/or its affiliates.
7 : *
8 : * OpenOffice.org - a multi-platform office productivity suite
9 : *
10 : * This file is part of OpenOffice.org.
11 : *
12 : * OpenOffice.org is free software: you can redistribute it and/or modify
13 : * it under the terms of the GNU Lesser General Public License version 3
14 : * only, as published by the Free Software Foundation.
15 : *
16 : * OpenOffice.org is distributed in the hope that it will be useful,
17 : * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 : * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 : * GNU Lesser General Public License version 3 for more details
20 : * (a copy is included in the LICENSE file that accompanied this code).
21 : *
22 : * You should have received a copy of the GNU Lesser General Public License
23 : * version 3 along with OpenOffice.org. If not, see
24 : * <http://www.openoffice.org/license.html>
25 : * for a copy of the LGPLv3 License.
26 : *
27 : ************************************************************************/
28 : #ifndef INCLUDED_EXTENSIONS_SOURCE_PLUGIN_INC_PLUGIN_UNX_PLUGCON_HXX
29 : #define INCLUDED_EXTENSIONS_SOURCE_PLUGIN_INC_PLUGIN_UNX_PLUGCON_HXX
30 :
31 : #include <stdarg.h>
32 : #include <string.h>
33 :
34 : #include <list>
35 : #include <vector>
36 : #include <plugin/unx/mediator.hxx>
37 :
38 : #if defined SOLARIS
39 : # define USE_MOTIF
40 : #endif
41 :
42 : #include <prex.h>
43 :
44 : #include <X11/Xlib.h>
45 : extern "C" {
46 : #include <X11/Intrinsic.h>
47 : }
48 : #include <X11/Shell.h>
49 : #include <X11/IntrinsicP.h> /* Intrinsics Definitions*/
50 : #include <X11/StringDefs.h> /* Standard Name-String definitions*/
51 : #if defined USE_MOTIF
52 : #include <Xm/DrawingA.h>
53 : #else
54 : #include <X11/Composite.h>
55 : #endif
56 : #include <X11/Xatom.h>
57 : #ifndef XP_UNIX
58 : # define XP_UNIX
59 : #endif
60 : #define MOZ_X11
61 : #include <stdio.h>
62 : #ifdef SYSTEM_MOZILLA
63 : #ifndef OJI
64 : # define OJI
65 : #endif
66 : #define MOZ_X11
67 : #endif
68 :
69 : #if ! defined ( _NPAPI_H_) && ! defined (npapi_h_)
70 : extern "C" {
71 : #include <npsdk/npupp.h>
72 : }
73 : #include "npapi.h"
74 :
75 : #if NP_VERSION_MINOR < 17
76 : // compatibility hack: compile with older NPN api header, but define
77 : // some later introduced constants
78 : // for gcc 3
79 : #define NP_ABI_MASK 0x10000000
80 : #define NPNVSupportsXEmbedBool ((NPNVariable)14)
81 : #define NPPVpluginNeedsXEmbed ((NPPVariable)14)
82 : #define NPNVToolkit ((int)(13 | NP_ABI_MASK))
83 : #define NPNVGtk12 1
84 : #define NPNVGtk2 2
85 : #endif
86 : #endif
87 :
88 : #include <config_vclplug.h>
89 :
90 : #if ENABLE_GTK
91 : #define GLIB_DISABLE_DEPRECATION_WARNINGS
92 : #include <gtk/gtk.h>
93 : #include <gdk/gdkx.h>
94 : #else
95 : #define GtkWidget void
96 : #endif
97 :
98 : #include <postx.h>
99 :
100 : class ConnectorInstance
101 : {
102 : public:
103 : NPP instance;
104 : NPWindow window;
105 : NPSetWindowCallbackStruct ws_info;
106 : char* pMimeType;
107 : void* pShell;
108 : void* pWidget;
109 : void* pForm;
110 :
111 : GtkWidget* pGtkWindow;
112 : GtkWidget* pGtkWidget;
113 :
114 : bool bShouldUseXEmbed;
115 :
116 : int nArg;
117 : char** argn;
118 : char** argv;
119 : char* pArgnBuf;
120 : char* pArgvBuf;
121 : NPSavedData aData;
122 :
123 : ConnectorInstance( NPP inst, char* type,
124 : int args, char* pargnbuf, sal_uLong nargnbytes,
125 : char* pargvbuf, sal_uLong nargvbytes,
126 : char* savedata, sal_uLong savebytes );
127 : ~ConnectorInstance();
128 : };
129 :
130 : class PluginConnector : public Mediator
131 : {
132 : protected:
133 : osl::Mutex m_aUserEventMutex;
134 :
135 : static std::vector<PluginConnector*> allConnectors;
136 :
137 : DECL_LINK( NewMessageHdl, Mediator* );
138 : DECL_LINK( WorkOnNewMessageHdl, Mediator* );
139 :
140 : std::vector<NPStream*> m_aNPWrapStreams;
141 : std::vector<ConnectorInstance*> m_aInstances;
142 :
143 : sal_uLong FillBuffer( char*&, const char*, sal_uLong, va_list );
144 : public:
145 : PluginConnector( int nSocket );
146 : virtual ~PluginConnector();
147 :
148 : virtual MediatorMessage* WaitForAnswer( sal_uLong nMessageID ) SAL_OVERRIDE;
149 : MediatorMessage* Transact( const char*, sal_uLong, ... );
150 : MediatorMessage* Transact( sal_uInt32, ... );
151 : void Respond( sal_uLong nID, char*, sal_uLong, ... );
152 : sal_uLong Send( sal_uInt32, ... );
153 :
154 : static const sal_uInt32 UnknownStreamID = 0xffffffff;
155 : static const sal_uInt32 UnknownNPPID = 0xffffffff;
156 :
157 : sal_uInt32 GetStreamID( NPStream* pStream );
158 : sal_uInt32 GetNPPID( NPP );
159 :
160 0 : std::vector<NPStream*>& getStreamList() { return m_aNPWrapStreams; }
161 :
162 0 : NPError GetNPError( MediatorMessage* pMes )
163 : {
164 0 : NPError* pErr = (NPError*)pMes->GetBytes();
165 0 : NPError aErr = *pErr;
166 0 : delete [] pErr;
167 0 : return aErr;
168 : }
169 :
170 0 : void CallWorkHandler()
171 : {
172 : LINK( this, PluginConnector, WorkOnNewMessageHdl ).
173 0 : Call( (Mediator*)this );
174 0 : }
175 : };
176 :
177 : enum CommandAtoms
178 : {
179 : eNPN_GetURL,
180 : eNPN_GetURLNotify,
181 : eNPN_DestroyStream,
182 : eNPN_NewStream,
183 : eNPN_PostURLNotify,
184 : eNPN_PostURL,
185 : eNPN_RequestRead,
186 : eNPN_Status,
187 : eNPN_Version,
188 : eNPN_Write,
189 : eNPN_UserAgent,
190 :
191 : eNPP_DestroyStream,
192 : eNPP_Destroy,
193 : eNPP_DestroyPhase2,
194 : eNPP_NewStream,
195 : eNPP_New,
196 : eNPP_SetWindow,
197 : eNPP_StreamAsFile,
198 : eNPP_URLNotify,
199 : eNPP_WriteReady,
200 : eNPP_Write,
201 : eNPP_GetMIMEDescription,
202 : eNPP_Initialize,
203 : eNPP_Shutdown,
204 :
205 : eMaxCommand
206 : };
207 :
208 : const char* GetCommandName( CommandAtoms );
209 :
210 : #define POST_STRING( x ) x ? x : const_cast<char*>(""), x ? strlen(x) : 1
211 :
212 : #endif // INCLUDED_EXTENSIONS_SOURCE_PLUGIN_INC_PLUGIN_UNX_PLUGCON_HXX
213 :
214 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|