"Fossies" - the Fresh Open Source Software Archive 
Member "mozplugger-2.1.6/npn-get-helpers.c" (17 Apr 2014, 6252 Bytes) of package /linux/www/old/mozplugger-2.1.6.tar.gz:
As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) C and C++ source code syntax highlighting (style:
standard) with prefixed line numbers and
code folding option.
Alternatively you can here
view or
download the uninterpreted source code file.
1 /**
2 * This file is part of mozplugger a fork of plugger, for list of developers
3 * see the README file.
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA.
18 */
19
20 #include "npapi.h"
21 #include "npruntime.h"
22 #include "npn_func_tab.h"
23 #include "npp_func_tab.h"
24 #include "npn_funcs.h"
25
26
27 #include "debug.h"
28
29 static int browserApiMajorVer = 0;
30 static int browserApiMinorVer = 0;
31
32 /**
33 * Get information about the browser this plugin is running under
34 *
35 */
36 void get_api_version(void)
37 {
38 int pluginApiMajorVer;
39 int pluginApiMinorVer;
40
41 NPN_Version(&browserApiMajorVer, &browserApiMinorVer);
42
43 NPP_Version(&pluginApiMajorVer, &pluginApiMinorVer);
44
45 D("NPN_Version() - API versions plugin=%d.%d Browser=%d.%d\n",
46 pluginApiMajorVer, pluginApiMinorVer,
47 browserApiMajorVer, browserApiMinorVer);
48 }
49
50
51 /**
52 * Find out if browser has the resize bug
53 *
54 * @return 1 if so
55 */
56 NPBool does_browser_have_resize_bug(void)
57 {
58 /* Mozilla work around not require for versions > 0.13 */
59 if((browserApiMajorVer > 0) || (browserApiMinorVer > 13))
60 {
61 return 0;
62 }
63 return 1;
64 }
65
66 /**
67 * Find out if browser supports XEmbed
68 *
69 * @return 1 if so
70 */
71 NPBool does_browser_support_xembed(void)
72 {
73 NPBool value;
74 /* Check if browser supports XEmbed and also what toolkit the browser
75 * uses */
76 NPError err = NPN_GetValue((void *)0, NPNVSupportsXEmbedBool, (void*) &value);
77 if(err != NPERR_NO_ERROR)
78 {
79 D("NPN_GetValue(NPNVSupportsXEmbedBool) - Browser returned err=%i\n",
80 err);
81 return 0;
82 }
83
84
85 D("NPN_GetValue(NPNSupportsXEmbedBool) - Browser returned %i\n", value);
86 return value;
87 }
88
89 /**
90 * Find out which toolkit the browser supports
91 *
92 * @param[in] instance The instance pointer
93 *
94 * @return the toolkit type
95 */
96 NPNToolkitType get_browser_toolkit(NPP instance)
97 {
98 NPNToolkitType value;
99 /* Get tool kit supported */
100 NPError err = NPN_GetValue(instance, NPNVToolkit, (void *) &value);
101 if(err != NPERR_NO_ERROR)
102 {
103 D("NPN_GetValue(NPNVToolkit) - Browser returned err=%i\n", err);
104 return 0;
105 }
106
107 switch(value)
108 {
109 case NPNVGtk12:
110 D("NPN_GetValue(NPNVToolkit) - Browser supports GTK1.2\n");
111 break;
112
113 case NPNVGtk2:
114 D("NPN_GetValue(NPNToolkit) - Browser supports GTK2\n");
115 break;
116 }
117 return value;
118 }
119
120
121 /**
122 * Find out if browser supports advanced key handling for this instance of the
123 * plugin
124 *
125 * @param[in] instance The instance pointer
126 *
127 * @return 1 if so
128 */
129 NPBool does_browser_support_key_handling(NPP instance)
130 {
131 NPBool value;
132 /* Get Advanced Keyboard focus */
133 NPError err = NPN_GetValue(instance, NPNVsupportsAdvancedKeyHandling,
134 (void *) &value);
135 if(err != NPERR_NO_ERROR)
136 {
137 D("NPN_GetValue(NPNVSupportsAdvancedKeyHandling) - "
138 "Browser returned err=%i\n", err);
139 return 0;
140 }
141
142
143 D("NPN_GetValue(NPNVSupportsAdvancedKeyHandling) - "
144 "Browser returned %i\n", value);
145 return value;
146 }
147
148 /**
149 * Convert enum to string
150 *
151 * @param[in] variable The enum value of the variable
152 *
153 * @return pointer to const string
154 */
155 const char * NPPVariableToString(NPPVariable variable)
156 {
157 const char * varName;
158
159 switch (variable)
160 {
161 case NPPVpluginNameString:
162 varName = "NPPVpluginNameString";
163 break;
164
165 case NPPVpluginDescriptionString:
166 varName = "NPPVpluginDescriptionString";
167 break;
168
169 case NPPVpluginNeedsXEmbed:
170 varName = "NPPVpluginNeedsXEmbed";
171 break;
172
173 case NPPVpluginScriptableNPObject :
174 varName = "NPPVpluginScriptableNPObject";
175 break;
176
177 case NPPVpluginWindowBool:
178 varName = "NPPVpluginWindowBool";
179 break;
180
181 case NPPVpluginTransparentBool:
182 varName = "NPPVpluginTransparentBool";
183 break;
184
185 case NPPVjavaClass:
186 varName = "NPPVjavaClass";
187 break;
188
189 case NPPVpluginWindowSize:
190 varName = "NPPVpluginWindowSize";
191 break;
192
193 case NPPVpluginTimerInterval:
194 varName = "NPPVpluginTimerInterval";
195 break;
196
197 case NPPVpluginScriptableInstance:
198 varName = "NPPVpluginScriptableInstance";
199 break;
200
201 case NPPVpluginScriptableIID:
202 varName = "NPPVpluginScriptableIID";
203 break;
204
205 case NPPVjavascriptPushCallerBool:
206 varName = "NPPVjavascriptPushCallerBool";
207 break;
208
209 case NPPVpluginKeepLibraryInMemory:
210 varName = "NPPVpluginKeepLibraryInMemory";
211 break;
212
213 case NPPVformValue:
214 varName = "NPPVformValue";
215 break;
216
217 case NPPVpluginUrlRequestsDisplayedBool:
218 varName = "NPPVpluginUrlRequestsDisplayedBool";
219 break;
220
221 case NPPVpluginWantsAllNetworkStreams:
222 varName = "NPPVpluginWantsNetworkStreams";
223 break;
224
225 case NPPVpluginNativeAccessibleAtkPlugId:
226 varName = "NPPVpluginNativeAccessibleAtkPlugId";
227 break;
228
229 case NPPVpluginCancelSrcStream:
230 varName = "NPPVpluginCancelSrcStream";
231 break;
232
233 case NPPVsupportsAdvancedKeyHandling:
234 varName = "NPPVsupportsAdvancedKeyHandling";
235 break;
236
237 case NPPVpluginUsesDOMForCursorBool:
238 varName = "NPPVpluginUsesDOMForCursorBool";
239 break;
240
241 default:
242 varName = "unknown";
243 break;
244 }
245 return varName;
246 }
247