Changeset 418 for trunk/icedtea-web/plugin/icedteanp
- Timestamp:
- Feb 11, 2013, 8:53:47 PM (13 years ago)
- Location:
- trunk/icedtea-web
- Files:
-
- 19 edited
-
. (modified) (1 prop)
-
plugin/icedteanp/IcedTeaJavaRequestProcessor.cc (modified) (5 diffs)
-
plugin/icedteanp/IcedTeaNPPlugin.cc (modified) (23 diffs)
-
plugin/icedteanp/IcedTeaPluginRequestProcessor.cc (modified) (23 diffs)
-
plugin/icedteanp/IcedTeaPluginUtils.cc (modified) (15 diffs)
-
plugin/icedteanp/IcedTeaPluginUtils.h (modified) (2 diffs)
-
plugin/icedteanp/java/netscape/javascript/JSObject.java (modified) (2 diffs)
-
plugin/icedteanp/java/sun/applet/AppletSecurityContextManager.java (modified) (1 diff)
-
plugin/icedteanp/java/sun/applet/GetMemberPluginCallRequest.java (modified) (1 diff)
-
plugin/icedteanp/java/sun/applet/JavaConsole.java (modified) (3 diffs)
-
plugin/icedteanp/java/sun/applet/PluginAppletSecurityContext.java (modified) (2 diffs)
-
plugin/icedteanp/java/sun/applet/PluginAppletViewer.java (modified) (5 diffs)
-
plugin/icedteanp/java/sun/applet/PluginCallRequest.java (modified) (1 diff)
-
plugin/icedteanp/java/sun/applet/PluginCallRequestFactory.java (modified) (2 diffs)
-
plugin/icedteanp/java/sun/applet/PluginCookieManager.java (modified) (2 diffs)
-
plugin/icedteanp/java/sun/applet/PluginException.java (modified) (1 diff)
-
plugin/icedteanp/java/sun/applet/PluginMain.java (modified) (2 diffs)
-
plugin/icedteanp/java/sun/applet/PluginMessageHandlerWorker.java (modified) (1 diff)
-
plugin/icedteanp/java/sun/applet/PluginStreamHandler.java (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/icedtea-web
-
Property svn:mergeinfo
set to
/branches/vendor/sourceforge/icedtea-web/1.3 merged eligible /branches/vendor/sourceforge/icedtea-web/current merged eligible
-
Property svn:mergeinfo
set to
-
trunk/icedtea-web/plugin/icedteanp/IcedTeaJavaRequestProcessor.cc
r358 r418 921 921 { 922 922 className = "java.lang.String"; 923 #if MOZILLA_VERSION_COLLAPSED < 1090200 924 stringArg += NPVARIANT_TO_STRING(variant).utf8characters; 925 #else 926 stringArg += NPVARIANT_TO_STRING(variant).UTF8Characters; 927 #endif 923 stringArg = IcedTeaPluginUtilities::NPVariantAsString(variant); 928 924 } else if (NPVARIANT_IS_OBJECT(variant)) 929 925 { … … 938 934 PLUGIN_DEBUG("NPObject is not a Java object\n"); 939 935 NPIdentifier length_id = browser_functions.getstringidentifier("length"); 936 bool isJSObjectArray = false; 940 937 941 938 // FIXME: We currently only handle <= 2 dim arrays. Do we really need more though? … … 953 950 IcedTeaPluginUtilities::itoa(NPVARIANT_TO_INT32(length), &length_str); 954 951 955 if (NPVARIANT_TO_INT32(length) > 0)952 if (NPVARIANT_TO_INT32(length) >= 0) 956 953 { 957 954 NPIdentifier id_0 = browser_functions.getintidentifier(0); … … 973 970 getArrayTypeForJava(instance, first_element, &java_array_type); 974 971 } 975 } else 976 java_array_type.append("jsobject"); 972 } 973 974 // For JSObject arrays, we create a regular object (accessible via JSObject.getSlot()) 975 if (NPVARIANT_TO_INT32(length) < 0 || !java_array_type.compare("jsobject")) 976 { 977 isJSObjectArray = true; 978 goto createRegularObject; 979 } 977 980 978 981 java_result = java_request.newArray(java_array_type, length_str); … … 1012 1015 // Got here => no errors above. We're good to return! 1013 1016 return; 1014 } else // Else it is not an array 1017 } 1018 1019 createRegularObject: 1020 if (!IcedTeaPluginUtilities::isObjectJSArray(instance, obj) || isJSObjectArray) // Else it is not an array 1015 1021 { 1016 1022 -
trunk/icedtea-web/plugin/icedteanp/IcedTeaNPPlugin.cc
r394 r418 108 108 #define PLUGIN_FULL_NAME PLUGIN_NAME " (using " PLUGIN_VERSION ")" 109 109 #define PLUGIN_DESC "The <a href=\"" PACKAGE_URL "\">" PLUGIN_NAME "</a> executes Java applets." 110 111 #ifdef HAVE_JAVA7 112 #define JPI_VERSION "1.7.0_" JDK_UPDATE_VERSION 113 #define PLUGIN_APPLET_MIME_DESC7 \ 114 "application/x-java-applet;version=1.7:class,jar:IcedTea;" 115 #define PLUGIN_BEAN_MIME_DESC7 \ 116 "application/x-java-bean;version=1.7:class,jar:IcedTea;" 117 #else 118 #define JPI_VERSION "1.6.0_" JDK_UPDATE_VERSION 119 #define PLUGIN_APPLET_MIME_DESC7 120 #define PLUGIN_BEAN_MIME_DESC7 121 #endif 110 122 111 123 #define PLUGIN_MIME_DESC \ … … 126 138 "application/x-java-applet;version=1.5:class,jar:IcedTea;" \ 127 139 "application/x-java-applet;version=1.6:class,jar:IcedTea;" \ 128 "application/x-java-applet;jpi-version=1.6.0_" JDK_UPDATE_VERSION ":class,jar:IcedTea;" \ 140 PLUGIN_APPLET_MIME_DESC7 \ 141 "application/x-java-applet;jpi-version=" JPI_VERSION ":class,jar:IcedTea;" \ 129 142 "application/x-java-bean:class,jar:IcedTea;" \ 130 143 "application/x-java-bean;version=1.1:class,jar:IcedTea;" \ … … 142 155 "application/x-java-bean;version=1.5:class,jar:IcedTea;" \ 143 156 "application/x-java-bean;version=1.6:class,jar:IcedTea;" \ 144 "application/x-java-bean;jpi-version=1.6.0_" JDK_UPDATE_VERSION ":class,jar:IcedTea;" \ 157 PLUGIN_BEAN_MIME_DESC7 \ 158 "application/x-java-bean;jpi-version=" JPI_VERSION ":class,jar:IcedTea;" \ 145 159 "application/x-java-vm-npruntime::IcedTea;" 146 160 … … 280 294 pthread_cond_t cond_message_available = PTHREAD_COND_INITIALIZER; 281 295 296 297 #ifdef LEGACY_GLIB 298 // Returns key from first item stored in hashtable 299 gboolean 300 find_first_item_in_hash_table(gpointer key, gpointer value, gpointer user_data) 301 { 302 user_data = key; 303 return (gboolean)TRUE; 304 } 305 306 int 307 g_strcmp0(char *str1, char *str2) 308 { 309 if (str1 != NULL) 310 return str2 != NULL ? strcmp(str1, str2) : 1; 311 else // str1 == NULL 312 return str2 != NULL ? 1 : 0; 313 } 314 315 316 #endif 317 318 319 /* 320 * Find first member in GHashTable* depending on version of glib 321 */ 322 gpointer getFirstInTableInstance(GHashTable* table) 323 { 324 gpointer id, instance; 325 #ifndef LEGACY_GLIB 326 GHashTableIter iter; 327 g_hash_table_iter_init (&iter, table); 328 g_hash_table_iter_next (&iter, &instance, &id); 329 #else 330 g_hash_table_find(table, (GHRFunc)find_first_item_in_hash_table, &instance); 331 #endif 332 return instance; 333 } 334 282 335 // Functions prefixed by ITNP_ are instance functions. They are called 283 336 // by the browser and operate on instances of ITNPPluginData. … … 405 458 406 459 cleanup_appletviewer_mutex: 407 g_ free (data->appletviewer_mutex);460 g_mutex_free (data->appletviewer_mutex); 408 461 data->appletviewer_mutex = NULL; 409 462 … … 965 1018 get_cookie_info(const char* siteAddr, char** cookieString, uint32_t* len) 966 1019 { 1020 // Only attempt to perform this operation if there is a valid plugin instance 1021 if (g_hash_table_size(instance_to_id_map) <= 0) 1022 { 1023 return NPERR_GENERIC_ERROR; 1024 } 967 1025 #if MOZILLA_VERSION_COLLAPSED < 1090100 968 1026 nsresult rv; … … 1008 1066 if (browser_functions.getvalueforurl) 1009 1067 { 1010 GHashTableIter iter; 1011 gpointer id, instance; 1012 1013 g_hash_table_iter_init (&iter, instance_to_id_map); 1014 g_hash_table_iter_next (&iter, &instance, &id); 1015 1068 gpointer instance=getFirstInTableInstance(instance_to_id_map); 1016 1069 return browser_functions.getvalueforurl((NPP) instance, NPNURLVCookie, siteAddr, cookieString, len); 1017 1070 } else … … 1023 1076 1024 1077 return NPERR_NO_ERROR; 1078 } 1079 1080 static NPError 1081 set_cookie_info(const char* siteAddr, const char* cookieString, uint32_t len) 1082 { 1083 // Only attempt to perform this operation if there is a valid plugin instance 1084 if (g_hash_table_size(instance_to_id_map) > 0 && browser_functions.getvalueforurl) 1085 { 1086 // We arbitrarily use the first valid instance we can grab 1087 // For an explanation of the logic behind this, see get_cookie_info 1088 gpointer instance = getFirstInTableInstance(instance_to_id_map); 1089 return browser_functions.setvalueforurl((NPP) instance, NPNURLVCookie, siteAddr, cookieString, len); 1090 } 1091 1092 return NPERR_GENERIC_ERROR;; 1025 1093 } 1026 1094 … … 1138 1206 href_id, &href); 1139 1207 1140 // Strip everything after the last "/" 1141 #if MOZILLA_VERSION_COLLAPSED < 1090200 1142 gchar** parts = g_strsplit (NPVARIANT_TO_STRING(href).utf8characters, "/", -1); 1143 #else 1144 gchar** parts = g_strsplit (NPVARIANT_TO_STRING(href).UTF8Characters, "/", -1); 1145 #endif 1146 guint parts_sz = g_strv_length (parts); 1147 1148 std::string location_str; 1149 for (int i=0; i < parts_sz - 1; i++) 1150 { 1151 location_str += parts[i]; 1152 location_str += "/"; 1153 } 1154 1155 documentbase_copy = g_strdup (location_str.c_str()); 1208 std::string href_str = IcedTeaPluginUtilities::NPVariantAsString(href); 1209 documentbase_copy = g_strdup (href_str.c_str()); 1156 1210 1157 1211 // Release references. … … 1258 1312 } 1259 1313 1314 static 1315 void consume_plugin_message(gchar* message) { 1316 // internal plugin related message 1317 gchar** parts = g_strsplit (message, " ", 5); 1318 if (g_str_has_prefix(parts[1], "PluginProxyInfo")) 1319 { 1320 gchar* proxy; 1321 uint32_t len; 1322 1323 gchar* decoded_url = (gchar*) calloc(strlen(parts[4]) + 1, sizeof(gchar)); 1324 IcedTeaPluginUtilities::decodeURL(parts[4], &decoded_url); 1325 PLUGIN_DEBUG("parts[0]=%s, parts[1]=%s, reference, parts[3]=%s, parts[4]=%s -- decoded_url=%s\n", parts[0], parts[1], parts[3], parts[4], decoded_url); 1326 1327 gchar* proxy_info; 1328 1329 #if MOZILLA_VERSION_COLLAPSED < 1090100 1330 proxy = (char*) malloc(sizeof(char)*2048); 1331 #endif 1332 1333 proxy_info = g_strconcat ("plugin PluginProxyInfo reference ", parts[3], " ", NULL); 1334 if (get_proxy_info(decoded_url, &proxy, &len) == NPERR_NO_ERROR) 1335 { 1336 proxy_info = g_strconcat (proxy_info, proxy, NULL); 1337 } 1338 1339 PLUGIN_DEBUG("Proxy info: %s\n", proxy_info); 1340 plugin_send_message_to_appletviewer(proxy_info); 1341 1342 free(decoded_url); 1343 decoded_url = NULL; 1344 g_free(proxy_info); 1345 proxy_info = NULL; 1346 1347 #if MOZILLA_VERSION_COLLAPSED < 1090100 1348 g_free(proxy); 1349 proxy = NULL; 1350 #endif 1351 1352 } else if (g_str_has_prefix(parts[1], "PluginCookieInfo")) 1353 { 1354 gchar* decoded_url = (gchar*) calloc(strlen(parts[4])+1, sizeof(gchar)); 1355 IcedTeaPluginUtilities::decodeURL(parts[4], &decoded_url); 1356 1357 gchar* cookie_info = g_strconcat ("plugin PluginCookieInfo reference ", parts[3], " ", NULL); 1358 gchar* cookie_string; 1359 uint32_t len; 1360 if (get_cookie_info(decoded_url, &cookie_string, &len) == NPERR_NO_ERROR) 1361 { 1362 cookie_info = g_strconcat (cookie_info, cookie_string, NULL); 1363 } 1364 1365 PLUGIN_DEBUG("Cookie info: %s\n", cookie_info); 1366 plugin_send_message_to_appletviewer(cookie_info); 1367 1368 free(decoded_url); 1369 decoded_url = NULL; 1370 g_free(cookie_info); 1371 cookie_info = NULL; 1372 } else if (g_str_has_prefix(parts[1], "PluginSetCookie")) 1373 { 1374 // Message structure: plugin PluginSetCookie reference -1 <url> <cookie> 1375 gchar** cookie_parts = g_strsplit (message, " ", 6); 1376 1377 if (g_strv_length(cookie_parts) < 6) 1378 { 1379 g_strfreev (parts); 1380 g_strfreev (cookie_parts); 1381 return; // Defensive, message _should_ be properly formatted 1382 } 1383 1384 gchar* decoded_url = (gchar*) calloc(strlen(cookie_parts[4])+1, sizeof(gchar)); 1385 IcedTeaPluginUtilities::decodeURL(cookie_parts[4], &decoded_url); 1386 1387 gchar* cookie_string = cookie_parts[5]; 1388 uint32_t len = strlen(cookie_string); 1389 if (set_cookie_info(decoded_url, cookie_string, len) == NPERR_NO_ERROR) 1390 { 1391 PLUGIN_DEBUG("Setting cookie for URL %s to %s\n", decoded_url, cookie_string); 1392 } else 1393 { 1394 PLUGIN_DEBUG("Not able to set cookie for URL %s to %s\n", decoded_url, cookie_string); 1395 } 1396 1397 free(decoded_url); 1398 decoded_url = NULL; 1399 g_strfreev (cookie_parts); 1400 cookie_parts = NULL; 1401 } 1402 1403 g_strfreev (parts); 1404 parts = NULL; 1405 } 1406 1260 1407 void consume_message(gchar* message) { 1261 1408 … … 1287 1434 1288 1435 // clear the "instance X status" parts 1289 s printf(parts[0], "");1290 s printf(parts[1], "");1291 s printf(parts[2], "");1436 strcpy(parts[0], ""); 1437 strcpy(parts[1], ""); 1438 strcpy(parts[2], ""); 1292 1439 1293 1440 // join the rest … … 1320 1467 else if (g_str_has_prefix (message, "plugin ")) 1321 1468 { 1322 // internal plugin related message 1323 gchar** parts = g_strsplit (message, " ", 5); 1324 if (g_str_has_prefix(parts[1], "PluginProxyInfo")) 1325 { 1326 gchar* proxy; 1327 uint32_t len; 1328 1329 gchar* decoded_url = (gchar*) calloc(strlen(parts[4]) + 1, sizeof(gchar)); 1330 IcedTeaPluginUtilities::decodeURL(parts[4], &decoded_url); 1331 PLUGIN_DEBUG("parts[0]=%s, parts[1]=%s, reference, parts[3]=%s, parts[4]=%s -- decoded_url=%s\n", parts[0], parts[1], parts[3], parts[4], decoded_url); 1332 1333 gchar* proxy_info; 1334 1335 #if MOZILLA_VERSION_COLLAPSED < 1090100 1336 proxy = (char*) malloc(sizeof(char)*2048); 1337 #endif 1338 1339 proxy_info = g_strconcat ("plugin PluginProxyInfo reference ", parts[3], " ", NULL); 1340 if (get_proxy_info(decoded_url, &proxy, &len) == NPERR_NO_ERROR) 1341 { 1342 proxy_info = g_strconcat (proxy_info, proxy, NULL); 1343 } 1344 1345 PLUGIN_DEBUG("Proxy info: %s\n", proxy_info); 1346 plugin_send_message_to_appletviewer(proxy_info); 1347 1348 g_free(decoded_url); 1349 decoded_url = NULL; 1350 g_free(proxy_info); 1351 proxy_info = NULL; 1352 1353 #if MOZILLA_VERSION_COLLAPSED < 1090100 1354 g_free(proxy); 1355 proxy = NULL; 1356 #endif 1357 1358 } else if (g_str_has_prefix(parts[1], "PluginCookieInfo")) 1359 { 1360 gchar* decoded_url = (gchar*) calloc(strlen(parts[4])+1, sizeof(gchar)); 1361 IcedTeaPluginUtilities::decodeURL(parts[4], &decoded_url); 1362 1363 gchar* cookie_info = g_strconcat ("plugin PluginCookieInfo reference ", parts[3], " ", NULL); 1364 gchar* cookie_string; 1365 uint32_t len; 1366 if (get_cookie_info(decoded_url, &cookie_string, &len) == NPERR_NO_ERROR) 1367 { 1368 cookie_info = g_strconcat (cookie_info, cookie_string, NULL); 1369 } 1370 1371 PLUGIN_DEBUG("Cookie info: %s\n", cookie_info); 1372 plugin_send_message_to_appletviewer(cookie_info); 1373 1374 g_free(decoded_url); 1375 decoded_url = NULL; 1376 g_free(cookie_info); 1377 cookie_info = NULL; 1378 } 1469 consume_plugin_message(message); 1379 1470 } 1380 1471 else … … 1382 1473 g_print (" Unable to handle message: %s\n", message); 1383 1474 } 1475 1384 1476 } 1385 1477 … … 1401 1493 get_proxy_info(const char* siteAddr, char** proxy, uint32_t* len) 1402 1494 { 1495 // Only attempt to perform this operation if there is a valid plugin instance 1496 if (g_hash_table_size(instance_to_id_map) <= 0) 1497 { 1498 return NPERR_GENERIC_ERROR; 1499 } 1403 1500 #if MOZILLA_VERSION_COLLAPSED < 1090100 1404 1501 nsresult rv; … … 1475 1572 1476 1573 // As in get_cookie_info, we use the first active instance 1477 GHashTableIter iter; 1478 gpointer id, instance; 1479 1480 g_hash_table_iter_init (&iter, instance_to_id_map); 1481 g_hash_table_iter_next (&iter, &instance, &id); 1482 1574 gpointer instance=getFirstInTableInstance(instance_to_id_map); 1483 1575 browser_functions.getvalueforurl((NPP) instance, NPNURLVProxy, siteAddr, proxy, len); 1484 1576 } else … … 2086 2178 2087 2179 // cleanup_appletviewer_mutex: 2088 g_ free (tofree->appletviewer_mutex);2180 g_mutex_free (tofree->appletviewer_mutex); 2089 2181 tofree->appletviewer_mutex = NULL; 2090 2182 … … 2109 2201 } 2110 2202 2111 static NPError 2112 plugin_get_entry_points (NPPluginFuncs* pluginTable) 2113 { 2114 // Ensure that the plugin function table we've received is large 2115 // enough to store the number of functions that we may provide. 2116 if (pluginTable->size < sizeof (NPPluginFuncs)) 2117 { 2118 PLUGIN_ERROR ("Invalid plugin function table."); 2119 2120 return NPERR_INVALID_FUNCTABLE_ERROR; 2121 } 2122 2123 // Return to the browser the plugin functions that we implement. 2203 static bool 2204 initialize_browser_functions(const NPNetscapeFuncs* browserTable) 2205 { 2206 #if MOZILLA_VERSION_COLLAPSED < 1090100 2207 #define NPNETSCAPEFUNCS_LAST_FIELD_USED (browserTable->pluginthreadasynccall) 2208 #else 2209 #define NPNETSCAPEFUNCS_LAST_FIELD_USED (browserTable->setvalueforurl) 2210 #endif 2211 2212 //Determine the size in bytes, as a difference of the address past the last used field 2213 //And the browser table address 2214 size_t usedSize = (char*)(1 + &NPNETSCAPEFUNCS_LAST_FIELD_USED) - (char*)browserTable; 2215 2216 // compare the reported size versus the size we required 2217 if (browserTable->size < usedSize) 2218 { 2219 return false; 2220 } 2221 2222 //Ensure any unused fields are NULL 2223 memset(&browser_functions, 0, sizeof(NPNetscapeFuncs)); 2224 2225 //browserTable->size can be larger than sizeof(NPNetscapeFuncs) (PR1106) 2226 size_t copySize = browserTable->size < sizeof(NPNetscapeFuncs) ? 2227 browserTable->size : sizeof(NPNetscapeFuncs); 2228 2229 //Copy fields according to given size 2230 memcpy(&browser_functions, browserTable, copySize); 2231 2232 return true; 2233 } 2234 2235 /* Set the plugin table to the correct contents, taking care not to write past 2236 * the provided object space */ 2237 static bool 2238 initialize_plugin_table(NPPluginFuncs* pluginTable) 2239 { 2240 #define NPPLUGINFUNCS_LAST_FIELD_USED (pluginTable->getvalue) 2241 2242 //Determine the size in bytes, as a difference of the address past the last used field 2243 //And the browser table address 2244 size_t usedSize = (char*)(1 + &NPPLUGINFUNCS_LAST_FIELD_USED) - (char*)pluginTable; 2245 2246 // compare the reported size versus the size we required 2247 if (pluginTable->size < usedSize) 2248 return false; 2249 2124 2250 pluginTable->version = (NP_VERSION_MAJOR << 8) + NP_VERSION_MINOR; 2125 2251 pluginTable->size = sizeof (NPPluginFuncs); … … 2151 2277 #endif 2152 2278 2153 return NPERR_NO_ERROR;2279 return true; 2154 2280 } 2155 2281 … … 2200 2326 } 2201 2327 2202 // Ensure that the browser function table is large enough to store 2203 // the number of browser functions that we may use. 2204 if (browserTable->size < sizeof (NPNetscapeFuncs)) 2205 { 2206 fprintf (stderr, "ERROR: Invalid browser function table. Some functionality may be restricted.\n"); 2207 } 2208 2209 // Store in a local table the browser functions that we may use. 2210 browser_functions.size = browserTable->size; 2211 browser_functions.version = browserTable->version; 2212 browser_functions.geturlnotify = browserTable->geturlnotify; 2213 browser_functions.geturl = browserTable->geturl; 2214 browser_functions.posturlnotify = browserTable->posturlnotify; 2215 browser_functions.posturl = browserTable->posturl; 2216 browser_functions.requestread = browserTable->requestread; 2217 browser_functions.newstream = browserTable->newstream; 2218 browser_functions.write = browserTable->write; 2219 browser_functions.destroystream = browserTable->destroystream; 2220 browser_functions.status = browserTable->status; 2221 browser_functions.uagent = browserTable->uagent; 2222 browser_functions.memalloc = browserTable->memalloc; 2223 browser_functions.memfree = browserTable->memfree; 2224 browser_functions.memflush = browserTable->memflush; 2225 browser_functions.reloadplugins = browserTable->reloadplugins; 2226 browser_functions.getJavaEnv = browserTable->getJavaEnv; 2227 browser_functions.getJavaPeer = browserTable->getJavaPeer; 2228 browser_functions.getvalue = browserTable->getvalue; 2229 browser_functions.setvalue = browserTable->setvalue; 2230 browser_functions.invalidaterect = browserTable->invalidaterect; 2231 browser_functions.invalidateregion = browserTable->invalidateregion; 2232 browser_functions.forceredraw = browserTable->forceredraw; 2233 browser_functions.getstringidentifier = browserTable->getstringidentifier; 2234 browser_functions.getstringidentifiers = browserTable->getstringidentifiers; 2235 browser_functions.getintidentifier = browserTable->getintidentifier; 2236 browser_functions.identifierisstring = browserTable->identifierisstring; 2237 browser_functions.utf8fromidentifier = browserTable->utf8fromidentifier; 2238 browser_functions.intfromidentifier = browserTable->intfromidentifier; 2239 browser_functions.createobject = browserTable->createobject; 2240 browser_functions.retainobject = browserTable->retainobject; 2241 browser_functions.releaseobject = browserTable->releaseobject; 2242 browser_functions.invoke = browserTable->invoke; 2243 browser_functions.invokeDefault = browserTable->invokeDefault; 2244 browser_functions.evaluate = browserTable->evaluate; 2245 browser_functions.getproperty = browserTable->getproperty; 2246 browser_functions.setproperty = browserTable->setproperty; 2247 browser_functions.removeproperty = browserTable->removeproperty; 2248 browser_functions.hasproperty = browserTable->hasproperty; 2249 browser_functions.hasmethod = browserTable->hasmethod; 2250 browser_functions.releasevariantvalue = browserTable->releasevariantvalue; 2251 browser_functions.setexception = browserTable->setexception; 2252 browser_functions.pluginthreadasynccall = browserTable->pluginthreadasynccall; 2253 #if MOZILLA_VERSION_COLLAPSED >= 1090100 2254 browser_functions.getvalueforurl = browserTable->getvalueforurl; 2255 browser_functions.setvalueforurl = browserTable->setvalueforurl; 2256 #endif 2257 2258 NPError np_error = NPERR_NO_ERROR; 2328 // Copy into a global table (browser_functions) the browser functions that we may use. 2329 // If the browser functions needed change, update NPNETSCAPEFUNCS_LAST_FIELD_USED 2330 // within this function 2331 bool browser_functions_supported = initialize_browser_functions(browserTable); 2332 2333 // Check if everything we rely on is supported 2334 if ( !browser_functions_supported ) 2335 { 2336 PLUGIN_ERROR ("Invalid browser function table."); 2337 2338 return NPERR_INVALID_FUNCTABLE_ERROR; 2339 } 2340 2259 2341 #if !defined(_WIN32) && !defined (__OS2__) 2260 np_error = plugin_get_entry_points (pluginTable); 2261 if (np_error != NPERR_NO_ERROR) 2262 return np_error; 2342 // Return to the browser the plugin functions that we implement. 2343 // If the plugin functions needed change, update NPPLUGINFUNCS_LAST_FIELD_USED 2344 // within this function 2345 bool plugin_functions_supported = initialize_plugin_table(pluginTable); 2346 2347 // Check if everything we rely on is supported 2348 if ( !plugin_functions_supported ) 2349 { 2350 PLUGIN_ERROR ("Invalid plugin function table."); 2351 2352 return NPERR_INVALID_FUNCTABLE_ERROR; 2353 } 2263 2354 #endif 2264 2355 … … 2287 2378 return NPERR_OUT_OF_MEMORY_ERROR; 2288 2379 } 2380 NPError np_error = NPERR_NO_ERROR; 2381 gchar* filename = NULL; 2289 2382 2290 2383 // If P_tmpdir does not exist, try /tmp directly … … 2293 2386 (GFileTest) (G_FILE_TEST_EXISTS | G_FILE_TEST_IS_DIR))) 2294 2387 { 2388 int file_error = 0; 2389 2295 2390 data_directory = g_strconcat ("/tmp", NULL); 2296 2391 if (!data_directory) … … 2453 2548 } 2454 2549 2455 return plugin_get_entry_points (pluginTable); 2550 // Return to the browser the plugin functions that we implement. 2551 // If the plugin functions needed change, update NPPLUGINFUNCS_LAST_FIELD_USED 2552 // within this function 2553 bool plugin_functions_supported = initialize_plugin_table(pluginTable); 2554 2555 // Check if everything we rely on is supported 2556 if ( !plugin_functions_supported ) 2557 { 2558 PLUGIN_ERROR ("Invalid plugin function table."); 2559 2560 return NPERR_INVALID_FUNCTABLE_ERROR; 2561 } 2562 2563 return NPERR_NO_ERROR; 2456 2564 } 2457 2565 #endif … … 2459 2567 // Returns a string describing the MIME type that this plugin 2460 2568 // handles. 2461 const char* 2569 #ifdef LEGACY_XULRUNNERAPI 2570 char* 2571 #else 2572 const char* 2573 #endif 2462 2574 OSCALL NP_GetMIMEDescription () 2463 2575 { -
trunk/icedtea-web/plugin/icedteanp/IcedTeaPluginRequestProcessor.cc
r369 r418 124 124 this->sendWindow(message_parts); 125 125 return true; 126 } else if (!command->find("Finalize")) 127 { 128 // Object can be finalized from the main thread only. And this 129 // call returns immediately, so we do it in the same thread. 130 this->finalize(message_parts); 131 return true; 126 132 } else if (!command->find("GetMember") || 127 133 !command->find("SetMember") || … … 131 137 !command->find("SetSlot") || 132 138 !command->find("Eval") || 133 !command->find("Finalize") ||134 139 !command->find("LoadURL")) 135 140 { … … 242 247 IcedTeaPluginUtilities::callAndWaitForResult(instance, &_eval, &thread_data); 243 248 244 NPVariant* result_variant = (NPVariant*) IcedTeaPluginUtilities::stringToJSID(thread_data.result);245 std::string result_variant_jniid = std::string();246 createJavaObjectFromVariant(instance, *result_variant, &result_variant_jniid);247 248 249 IcedTeaPluginUtilities::constructMessagePrefix(0, reference, &response); 249 250 response += " JavaScriptEval "; 250 response += result_variant_jniid;251 response += thread_data.result; 251 252 252 253 plugin_to_java_bus->post(response.c_str()); … … 275 276 NPVariant* result_variant; 276 277 std::string result_variant_jniid = std::string(); 277 NPVariant* args_array ;278 NPVariant* args_array = NULL; 278 279 AsyncCallThreadData thread_data = AsyncCallThreadData(); 279 280 … … 331 332 IcedTeaPluginUtilities::callAndWaitForResult(instance, &_call, &thread_data); 332 333 333 result_variant = (NPVariant*) IcedTeaPluginUtilities::stringToJSID(thread_data.result);334 335 if (result_variant)336 {337 createJavaObjectFromVariant(instance, *result_variant, &result_variant_jniid);338 } else339 {340 result_variant_jniid = "0";341 }342 343 334 IcedTeaPluginUtilities::constructMessagePrefix(0, reference, &response); 344 335 response += " JavaScriptCall "; 345 response += result_variant_jniid;336 response += thread_data.result; 346 337 347 338 plugin_to_java_bus->post(response.c_str()); … … 410 401 NPP instance; 411 402 NPVariant* member; 412 NPIdentifier property_identifier; 403 std::string property_id = std::string(); 404 bool int_identifier; 413 405 414 406 JavaRequestProcessor java_request = JavaRequestProcessor(); … … 440 432 if (*(message_parts->at(4)) == "SetSlot") 441 433 { 442 property_identifier = browser_functions.getintidentifier(atoi(message_parts->at(6)->c_str())); 434 property_id.append(*(message_parts->at(6))); 435 int_identifier = true; 443 436 } else 444 437 { … … 452 445 } 453 446 454 property_identifier = browser_functions.getstringidentifier(java_result->return_string->c_str()); 447 property_id.append(*(java_result->return_string)); 448 int_identifier = false; 455 449 } 456 450 … … 462 456 thread_data.parameters.push_back(instance); 463 457 thread_data.parameters.push_back(NPVARIANT_TO_OBJECT(*member)); 464 thread_data.parameters.push_back(&property_id entifier);458 thread_data.parameters.push_back(&property_id); 465 459 thread_data.parameters.push_back(&value); 460 thread_data.parameters.push_back(&int_identifier); 466 461 467 462 IcedTeaPluginUtilities::callAndWaitForResult(instance, &_setMember, &thread_data); … … 478 473 * can only be requested from the main thread in Mozilla, this function 479 474 * does whatever it can seperately, and then makes an internal request that 480 * causes _ sendMember to do the rest of the work.475 * causes _getMember to do the rest of the work. 481 476 * 482 477 * @param message_parts The request message … … 491 486 JavaResultData* java_result; 492 487 NPVariant* parent_ptr; 488 NPVariant* member_ptr; 493 489 494 490 //int reference; 495 491 std::string member_id = std::string(); 496 std::string jsObjectClassID = std::string();497 std::string jsObjectConstructorID = std::string();498 492 std::string response = std::string(); 493 std::string result_id = std::string(); 499 494 500 495 NPIdentifier member_identifier; … … 503 498 int instance_id; 504 499 int reference; 500 bool int_identifier; 505 501 506 502 // debug printout of parent thread data … … 517 513 if (*(message_parts->at(4)) == "GetSlot") 518 514 { 519 member_identifier = browser_functions.getintidentifier(atoi(member_id.c_str()));515 int_identifier=true; 520 516 } else 521 517 { … … 530 526 } 531 527 532 member_identifier = browser_functions.getstringidentifier(java_result->return_string->c_str()); 528 member_id.assign(*(java_result->return_string)); 529 int_identifier=false; 533 530 } 534 531 … … 546 543 thread_data.parameters.push_back(instance); 547 544 thread_data.parameters.push_back(NPVARIANT_TO_OBJECT(*parent_ptr)); 548 thread_data.parameters.push_back(&member_identifier); 545 thread_data.parameters.push_back(&member_id); 546 thread_data.parameters.push_back(&int_identifier); 549 547 550 548 IcedTeaPluginUtilities::callAndWaitForResult(instance, &_getMember, &thread_data); 551 549 552 PLUGIN_DEBUG("Member PTR after internal request: %s\n", thread_data.result.c_str());553 554 java_result = java_request.findClass(0, "netscape.javascript.JSObject");555 556 // the result we want is in result_string (assuming there was no error)557 if (java_result->error_occurred)558 {559 printf("Unable to process getMember request. Error occurred: %s\n", java_result->error_msg->c_str());560 //goto cleanup;561 }562 563 jsObjectClassID.append(*(java_result->return_string));564 565 args = std::vector<std::string>();566 std::string longArg = "J";567 args.push_back(longArg);568 569 java_result = java_request.getMethodID(jsObjectClassID,570 browser_functions.getstringidentifier("<init>"),571 args);572 573 // the result we want is in result_string (assuming there was no error)574 if (java_result->error_occurred)575 {576 printf("Unable to process getMember request. Error occurred: %s\n", java_result->error_msg->c_str());577 //goto cleanup;578 }579 580 jsObjectConstructorID.append(*(java_result->return_string));581 582 // We have the method id. Now create a new object.583 584 args.clear();585 args.push_back(thread_data.result);586 java_result = java_request.newObjectWithConstructor("",587 jsObjectClassID,588 jsObjectConstructorID,589 args);590 591 // the result we want is in result_string (assuming there was no error)592 if (java_result->error_occurred)593 {594 printf("Unable to process getMember request. Error occurred: %s\n", java_result->error_msg->c_str());595 //goto cleanup;596 }597 598 599 550 IcedTeaPluginUtilities::constructMessagePrefix(0, reference, &response); 600 if (*(message_parts->at(2)) == "GetSlot") 601 { 551 if (*(message_parts->at(4)) == "GetSlot") 552 { 553 response.append(" JavaScriptGetSlot "); 554 } else { 602 555 response.append(" JavaScriptGetMember "); 603 } else { 604 response.append(" JavaScriptGetSlot "); 605 } 606 response.append(java_result->return_string->c_str()); 556 } 557 response.append(thread_data.result); 607 558 plugin_to_java_bus->post(response.c_str()); 608 559 } … … 764 715 processor->setMember(message_parts); 765 716 pthread_mutex_unlock(&syn_write_mutex); 766 } else if (command == "Finalize")767 {768 // write methods are synchronized769 pthread_mutex_lock(&syn_write_mutex);770 processor->finalize(message_parts);771 pthread_mutex_unlock(&syn_write_mutex);772 717 } else if (command == "LoadURL") // For instance X url <url> <target> 773 718 { … … 821 766 NPVariant value_variant = NPVariant(); 822 767 NPObject* member; 823 NPIdentifier* property; 768 NPIdentifier property_identifier; 769 824 770 825 771 std::vector<void*> parameters = ((AsyncCallThreadData*) data)->parameters; 826 772 instance = (NPP) parameters.at(0); 827 773 member = (NPObject*) parameters.at(1); 828 property = (NPIdentifier*) parameters.at(2);774 std::string* property_id = (std::string*) parameters.at(2); 829 775 value = (std::string*) parameters.at(3); 830 831 PLUGIN_DEBUG("Setting %s on instance %p, object %p to value %s\n", browser_functions.utf8fromidentifier(*property), instance, member, value->c_str()); 776 bool* int_identifier = (bool*) parameters.at(4); 777 778 if(*int_identifier==true) 779 property_identifier = browser_functions.getintidentifier(atoi(property_id->c_str())); 780 else 781 property_identifier = browser_functions.getstringidentifier(property_id->c_str()); 782 783 PLUGIN_DEBUG("Setting %s on instance %p, object %p to value %s\n", browser_functions.utf8fromidentifier(property_identifier), instance, member, value->c_str()); 832 784 833 785 IcedTeaPluginUtilities::javaResultToNPVariant(instance, value, &value_variant); 834 786 835 ((AsyncCallThreadData*) data)->call_successful = browser_functions.setproperty(instance, member, *property, &value_variant);787 ((AsyncCallThreadData*) data)->call_successful = browser_functions.setproperty(instance, member, property_identifier, &value_variant); 836 788 837 789 ((AsyncCallThreadData*) data)->result_ready = true; … … 850 802 instance = (NPP) parameters.at(0); 851 803 parent_ptr = (NPObject*) parameters.at(1); 852 NPIdentifier* member_identifier = (NPIdentifier*) parameters.at(2); 804 std::string* member_id = (std::string*) parameters.at(2); 805 NPIdentifier member_identifier; 806 807 bool* int_identifier = (bool*) parameters.at(3); 808 809 if(*int_identifier==true) 810 member_identifier = browser_functions.getintidentifier(atoi(member_id->c_str())); 811 else 812 member_identifier = browser_functions.getstringidentifier(member_id->c_str()); 853 813 854 814 // Get the NPVariant corresponding to this member 855 PLUGIN_DEBUG("Looking for %p %p %p (%s)\n", instance, parent_ptr, member_identifier, browser_functions.utf8fromidentifier( *member_identifier));856 857 if (!browser_functions.hasproperty(instance, parent_ptr, *member_identifier))858 { 859 printf("%s not found!\n", browser_functions.utf8fromidentifier( *member_identifier));860 } 861 ((AsyncCallThreadData*) data)->call_successful = browser_functions.getproperty(instance, parent_ptr, *member_identifier, member_ptr);815 PLUGIN_DEBUG("Looking for %p %p %p (%s)\n", instance, parent_ptr, member_identifier, browser_functions.utf8fromidentifier(member_identifier)); 816 817 if (!browser_functions.hasproperty(instance, parent_ptr, member_identifier)) 818 { 819 printf("%s not found!\n", browser_functions.utf8fromidentifier(member_identifier)); 820 } 821 ((AsyncCallThreadData*) data)->call_successful = browser_functions.getproperty(instance, parent_ptr, member_identifier, member_ptr); 862 822 863 823 IcedTeaPluginUtilities::printNPVariant(*member_ptr); … … 865 825 if (((AsyncCallThreadData*) data)->call_successful) 866 826 { 867 IcedTeaPluginUtilities::JSIDToString(member_ptr, &member_ptr_str);827 createJavaObjectFromVariant(instance, *member_ptr, &member_ptr_str); 868 828 ((AsyncCallThreadData*) data)->result.append(member_ptr_str); 829 869 830 } 870 831 ((AsyncCallThreadData*) data)->result_ready = true; … … 884 845 NPIdentifier script_identifier; 885 846 NPString script = NPString(); 886 NPVariant* eval_ result = new NPVariant();887 std::string eval_ result_ptr_str = std::string();847 NPVariant* eval_variant = new NPVariant(); 848 std::string eval_variant_str = std::string(); 888 849 889 850 PLUGIN_DEBUG("_eval called\n"); … … 899 860 script.utf8length = script_str->size(); 900 861 901 PLUGIN_DEBUG("Evaluating: %s\n", script .utf8characters);862 PLUGIN_DEBUG("Evaluating: %s\n", script_str->c_str()); 902 863 #else 903 864 script.UTF8Characters = script_str->c_str(); 904 865 script.UTF8Length = script_str->size(); 905 866 906 PLUGIN_DEBUG("Evaluating: %s\n", script .UTF8Characters);867 PLUGIN_DEBUG("Evaluating: %s\n", script_str->c_str()); 907 868 #endif 908 869 909 ((AsyncCallThreadData*) data)->call_successful = browser_functions.evaluate(instance, window_ptr, &script, eval_ result);910 IcedTeaPluginUtilities::printNPVariant(*eval_ result);870 ((AsyncCallThreadData*) data)->call_successful = browser_functions.evaluate(instance, window_ptr, &script, eval_variant); 871 IcedTeaPluginUtilities::printNPVariant(*eval_variant); 911 872 912 873 if (((AsyncCallThreadData*) data)->call_successful) 913 874 { 914 IcedTeaPluginUtilities::JSIDToString(eval_result, &eval_result_ptr_str); 915 ((AsyncCallThreadData*) data)->result.append(eval_result_ptr_str); 916 } 875 if (eval_variant) 876 { 877 createJavaObjectFromVariant(instance, *eval_variant, &eval_variant_str); 878 } else 879 { 880 eval_variant_str = "0"; 881 } 882 } else 883 { 884 eval_variant_str = "0"; 885 } 886 887 ((AsyncCallThreadData*) data)->result.append(eval_variant_str); 917 888 ((AsyncCallThreadData*) data)->result_ready = true; 918 889 … … 957 928 if (((AsyncCallThreadData*) data)->call_successful) 958 929 { 959 IcedTeaPluginUtilities::JSIDToString(call_result, &call_result_ptr_str); 960 ((AsyncCallThreadData*) data)->result.append(call_result_ptr_str); 961 } 962 930 931 if (call_result) 932 { 933 createJavaObjectFromVariant(instance, *call_result, &call_result_ptr_str); 934 } else 935 { 936 call_result_ptr_str = "0"; 937 } 938 } else 939 { 940 call_result_ptr_str = "0"; 941 } 942 943 ((AsyncCallThreadData*) data)->result.append(call_result_ptr_str); 963 944 ((AsyncCallThreadData*) data)->result_ready = true; 964 945 … … 1031 1012 ((AsyncCallThreadData*) data)->result_ready = true; 1032 1013 1033 g_free(decoded_url);1014 free(decoded_url); 1034 1015 decoded_url = NULL; 1035 1016 -
trunk/icedtea-web/plugin/icedteanp/IcedTeaPluginUtils.cc
r375 r418 151 151 IcedTeaPluginUtilities::JSIDToString(void* id, std::string* result) 152 152 { 153 154 char* id_str = (char*) malloc(sizeof(char)*20); // max = long long = 8446744073709551615 == 19 chars 153 char id_str[NUM_STR_BUFFER_SIZE]; 155 154 156 155 if (sizeof(void*) == sizeof(long long)) 157 156 { 158 s printf(id_str, "%llu", id);157 snprintf(id_str, NUM_STR_BUFFER_SIZE, "%llu", id); 159 158 } 160 159 else 161 160 { 162 s printf(id_str, "%lu", id); // else use long161 snprintf(id_str, NUM_STR_BUFFER_SIZE, "%lu", id); // else use long 163 162 } 164 163 … … 166 165 167 166 PLUGIN_DEBUG("Converting pointer %p to %s\n", id, id_str); 168 free(id_str);169 167 } 170 168 … … 262 260 IcedTeaPluginUtilities::itoa(int i, std::string* result) 263 261 { 264 // largest possible integer is 10 digits long 265 char* int_str = (char*) malloc(sizeof(char)*11); 266 sprintf(int_str, "%d", i); 262 char int_str[NUM_STR_BUFFER_SIZE]; 263 snprintf(int_str, NUM_STR_BUFFER_SIZE, "%d", i); 267 264 result->append(int_str); 268 269 free(int_str);270 265 } 271 266 … … 297 292 * @param str The string to split 298 293 * @param The delimiters to split on 299 * @return A string vector containing the aplit components294 * @return A string vector containing the split components 300 295 */ 301 296 … … 307 302 char* copy; 308 303 309 // Tokeni ngis done on a copy304 // Tokenization is done on a copy 310 305 copy = (char*) malloc (sizeof(char)*strlen(str) + 1); 311 306 strcpy(copy, str); … … 318 313 // Allocation on heap since caller has no way to knowing how much will 319 314 // be needed. Make sure caller cleans up! 320 std::string* s = new std::string();321 s->append(tok_ptr);322 v->push_back(s);323 tok_ptr = strtok (NULL, " ");315 std::string* s = new std::string(); 316 s->append(tok_ptr); 317 v->push_back(s); 318 tok_ptr = strtok (NULL, delim); 324 319 } 320 free(copy); 325 321 326 322 return v; … … 376 372 ostream << length; 377 373 378 // UTF-8 characters are 4-bytes max + space + '\0' 379 char* hex_value = (char*) malloc(sizeof(char)*10); 374 char hex_value[NUM_STR_BUFFER_SIZE]; 380 375 381 376 for (int i = 0; i < str->length(); i++) 382 377 { 383 s printf(hex_value," %hx", str->at(i));378 snprintf(hex_value, NUM_STR_BUFFER_SIZE," %hx", str->at(i)); 384 379 ostream << hex_value; 385 380 } … … 388 383 *utf_str = ostream.str(); 389 384 390 free(hex_value);391 385 PLUGIN_DEBUG("Converted %s to UTF-8 string %s\n", str->c_str(), utf_str->c_str()); 392 386 } … … 673 667 else if (NPVARIANT_IS_STRING(variant)) 674 668 { 675 #if MOZILLA_VERSION_COLLAPSED < 1090200 676 PLUGIN_DEBUG("STRING: %s\n", NPVARIANT_TO_STRING(variant).utf8characters); 677 #else 678 PLUGIN_DEBUG("STRING: %s\n", NPVARIANT_TO_STRING(variant).UTF8Characters); 679 #endif 669 std::string str = IcedTeaPluginUtilities::NPVariantAsString(variant); 670 PLUGIN_DEBUG("STRING: %s (length=%d)\n", str.c_str(), str.size()); 680 671 } 681 672 else … … 688 679 IcedTeaPluginUtilities::NPVariantToString(NPVariant variant, std::string* result) 689 680 { 690 char* str = (char*) malloc(sizeof(char)*32); // enough for everything except string 691 692 if (NPVARIANT_IS_VOID(variant)) 693 { 694 sprintf(str, "%p", variant); 695 } 696 else if (NPVARIANT_IS_NULL(variant)) 697 { 698 sprintf(str, "NULL"); 699 } 700 else if (NPVARIANT_IS_BOOLEAN(variant)) 701 { 702 if (NPVARIANT_TO_BOOLEAN(variant)) 703 sprintf(str, "true"); 704 else 705 sprintf(str, "false"); 706 } 707 else if (NPVARIANT_IS_INT32(variant)) 708 { 709 sprintf(str, "%d", NPVARIANT_TO_INT32(variant)); 710 } 711 else if (NPVARIANT_IS_DOUBLE(variant)) 712 { 713 sprintf(str, "%f", NPVARIANT_TO_DOUBLE(variant));; 714 } 715 else if (NPVARIANT_IS_STRING(variant)) 716 { 717 free(str); 718 #if MOZILLA_VERSION_COLLAPSED < 1090200 719 str = (char*) malloc(sizeof(char)*NPVARIANT_TO_STRING(variant).utf8length); 720 sprintf(str, "%s", NPVARIANT_TO_STRING(variant).utf8characters); 721 #else 722 str = (char*) malloc(sizeof(char)*NPVARIANT_TO_STRING(variant).UTF8Length); 723 sprintf(str, "%s", NPVARIANT_TO_STRING(variant).UTF8Characters); 724 #endif 725 } 681 char conv_str[NUM_STR_BUFFER_SIZE]; // conversion buffer 682 bool was_string_already = false; 683 684 if (NPVARIANT_IS_STRING(variant)) 685 { 686 result->append(IcedTeaPluginUtilities::NPVariantAsString(variant)); 687 was_string_already = true; 688 } 689 else if (NPVARIANT_IS_VOID(variant)) 690 { 691 snprintf(conv_str, NUM_STR_BUFFER_SIZE, "%p", variant); 692 } 693 else if (NPVARIANT_IS_NULL(variant)) 694 { 695 snprintf(conv_str, NUM_STR_BUFFER_SIZE, "NULL"); 696 } 697 else if (NPVARIANT_IS_BOOLEAN(variant)) 698 { 699 if (NPVARIANT_TO_BOOLEAN(variant)) 700 snprintf(conv_str, NUM_STR_BUFFER_SIZE, "true"); 726 701 else 727 { 728 sprintf(str, "[Object %p]", variant); 729 } 730 731 result->append(str); 732 free(str); 702 snprintf(conv_str, NUM_STR_BUFFER_SIZE, "false"); 703 } 704 else if (NPVARIANT_IS_INT32(variant)) 705 { 706 snprintf(conv_str, NUM_STR_BUFFER_SIZE, "%d", NPVARIANT_TO_INT32(variant)); 707 } 708 else if (NPVARIANT_IS_DOUBLE(variant)) 709 { 710 snprintf(conv_str, NUM_STR_BUFFER_SIZE, "%f", NPVARIANT_TO_DOUBLE(variant)); 711 } 712 else 713 { 714 snprintf(conv_str, NUM_STR_BUFFER_SIZE, "[Object %p]", variant); 715 } 716 717 if (!was_string_already){ 718 result->append(conv_str); 719 } 733 720 } 734 721 … … 869 856 IcedTeaPluginUtilities::printNPVariant(constructor_str); 870 857 871 std::string constructor_name = std::string(); 872 873 #if MOZILLA_VERSION_COLLAPSED < 1090200 874 constructor_name.append(NPVARIANT_TO_STRING(constructor_str).utf8characters); 875 #else 876 constructor_name.append(NPVARIANT_TO_STRING(constructor_str).UTF8Characters); 877 #endif 858 std::string constructor_name = IcedTeaPluginUtilities::NPVariantAsString(constructor_str); 878 859 879 860 PLUGIN_DEBUG("Constructor for NPObject is %s\n", constructor_name.c_str()); … … 918 899 } 919 900 901 /* Copies a variant data type into a C++ string */ 902 std::string 903 IcedTeaPluginUtilities::NPVariantAsString(NPVariant variant) 904 { 905 #if MOZILLA_VERSION_COLLAPSED < 1090200 906 return std::string( 907 NPVARIANT_TO_STRING(variant).utf8characters, 908 NPVARIANT_TO_STRING(variant).utf8length); 909 #else 910 return std::string( 911 NPVARIANT_TO_STRING(variant).UTF8Characters, 912 NPVARIANT_TO_STRING(variant).UTF8Length); 913 #endif 914 } 920 915 921 916 /** … … 1081 1076 PLUGIN_DEBUG("Error: Unable to initialize message queue mutex: %d\n", ret); 1082 1077 1083 PLUGIN_DEBUG("Mutex s %p and %p initialized\n", &subscriber_mutex, &msg_queue_mutex);1078 PLUGIN_DEBUG("Mutexes %p and %p initialized\n", &subscriber_mutex, &msg_queue_mutex); 1084 1079 } 1085 1080 … … 1145 1140 MessageBus::post(const char* message) 1146 1141 { 1147 char* msg = (char*) malloc(sizeof(char)*strlen(message) + 1);1148 1142 bool message_consumed = false; 1149 1150 // consumer frees this memory1151 strcpy(msg, message);1152 1143 1153 1144 PLUGIN_DEBUG("Trying to lock %p...\n", &msg_queue_mutex); 1154 1145 pthread_mutex_lock(&subscriber_mutex); 1155 1146 1156 PLUGIN_DEBUG("Message %s received on bus. Notifying subscribers.\n", m sg);1147 PLUGIN_DEBUG("Message %s received on bus. Notifying subscribers.\n", message); 1157 1148 1158 1149 std::list<BusSubscriber*>::const_iterator i; 1159 1150 for( i = subscribers.begin(); i != subscribers.end() && !message_consumed; ++i ) { 1160 PLUGIN_DEBUG("Notifying subscriber %p of %s\n", *i, m sg);1161 message_consumed = ((BusSubscriber*) *i)->newMessageOnBus(m sg);1151 PLUGIN_DEBUG("Notifying subscriber %p of %s\n", *i, message); 1152 message_consumed = ((BusSubscriber*) *i)->newMessageOnBus(message); 1162 1153 } 1163 1154 … … 1165 1156 1166 1157 if (!message_consumed) 1167 PLUGIN_DEBUG("Warning: No consumer found for message %s\n", m sg);1158 PLUGIN_DEBUG("Warning: No consumer found for message %s\n", message); 1168 1159 1169 1160 PLUGIN_DEBUG("%p unlocked...\n", &msg_queue_mutex); -
trunk/icedtea-web/plugin/icedteanp/IcedTeaPluginUtils.h
r375 r418 97 97 (*c >= 'A' && *c <= 'F')) 98 98 99 //long long max ~ 19 chars + terminator 100 //leave some room for converting strings like "<var> = %d" 101 const size_t NUM_STR_BUFFER_SIZE = 32; 102 99 103 /* 100 104 * This struct holds data specific to a Java operation requested by the plugin … … 206 210 static void itoa(int i, std::string* result); 207 211 212 /* Copies a variant data type into a C++ string */ 213 static std::string NPVariantAsString(NPVariant variant); 214 208 215 /* Frees the given vector and the strings that its contents point to */ 209 216 static void freeStringPtrVector(std::vector<std::string*>* v); -
trunk/icedtea-web/plugin/icedteanp/java/netscape/javascript/JSObject.java
r348 r418 131 131 boolean mayProceed = false; 132 132 133 for ( int i = 0; i < stack.length; i++) {134 if ( stack[i].getClassName().equals("netscape.javascript.JSObject") &&135 stack[i].getMethodName().equals("getWindow")) {133 for (StackTraceElement element : stack) { 134 if (element.getClassName().equals("netscape.javascript.JSObject") && 135 element.getMethodName().equals("getWindow")) { 136 136 mayProceed = true; 137 137 } … … 210 210 211 211 PluginDebug.debug("JSObject.call ", methodName); 212 for (int i = 0; i < args.length; i++) 213 PluginDebug.debug(" ", args[i]); 212 for (Object arg : args) { 213 PluginDebug.debug(" ", arg); 214 } 214 215 PluginDebug.debug(""); 215 216 return PluginAppletViewer.call(internal, methodName, args); -
trunk/icedtea-web/plugin/icedteanp/java/sun/applet/AppletSecurityContextManager.java
r348 r418 1 /* VoidPluginCallRequest -- represent Java-to-JavaScript requests 1 /* AppletSecurityContextManager -- handles messages in an appropriate security 2 context 3 2 4 Copyright (C) 2008 Red Hat 3 5 -
trunk/icedtea-web/plugin/icedteanp/java/sun/applet/GetMemberPluginCallRequest.java
r348 r418 51 51 // FIXME: Is it even possible to distinguish between null and void 52 52 // here? 53 if ( args[3] != "null" && args[3] != "void")53 if (!"null".equals(args[3]) && !"void".equals(args[3])) 54 54 object = AppletSecurityContextManager.getSecurityContext(0).getObject(Integer.parseInt(args[3])); 55 55 setDone(true); -
trunk/icedtea-web/plugin/icedteanp/java/sun/applet/JavaConsole.java
r348 r418 66 66 import net.sourceforge.jnlp.config.DeploymentConfiguration; 67 67 import net.sourceforge.jnlp.runtime.JNLPRuntime; 68 import net.sourceforge.jnlp.util.ImageResources; 68 69 69 70 /** … … 93 94 94 95 consoleWindow = new JFrame("Java Console"); 96 consoleWindow.setIconImages(ImageResources.INSTANCE.getApplicationImages()); 95 97 96 98 JPanel contentPanel = new JPanel(); … … 307 309 boolean toShowConsole = false; 308 310 309 for ( int i = 0; i < args.length; i++) {310 if ( args[i] == "--show-console") {311 for (String arg : args) { 312 if ("--show-console".equals(arg)) { 311 313 toShowConsole = true; 312 314 } -
trunk/icedtea-web/plugin/icedteanp/java/sun/applet/PluginAppletSecurityContext.java
r348 r418 244 244 if (System.getSecurityManager() == null) { 245 245 JNLPRuntime.initialize(/* isApplication */false); 246 JNLPRuntime.setDefaultLaunchHandler(new DefaultLaunchHandler( ));246 JNLPRuntime.setDefaultLaunchHandler(new DefaultLaunchHandler(System.err)); 247 247 } 248 248 … … 1296 1296 Permissions grantedPermissions = new Permissions(); 1297 1297 1298 for (int i = 0; i < nsPrivilegeList.length; i++) { 1299 String privilege = nsPrivilegeList[i]; 1300 1298 for (String privilege : nsPrivilegeList) { 1301 1299 if (privilege.equals("UniversalBrowserRead")) { 1302 1300 BrowserReadPermission bp = new BrowserReadPermission(); -
trunk/icedtea-web/plugin/icedteanp/java/sun/applet/PluginAppletViewer.java
r362 r418 123 123 124 124 public AppletPanel createPanel(PluginStreamHandler streamhandler, 125 int identifier,126 long handle, int x, int y,127 final URL doc,128 final Hashtable<String, String> atts) {125 final int identifier, 126 final long handle, int x, int y, 127 final URL doc, 128 final Hashtable<String, String> atts) { 129 129 final NetxPanel panel = AccessController.doPrivileged(new PrivilegedAction<NetxPanel>() { 130 130 public NetxPanel run() { … … 136 136 }); 137 137 138 // create the frame. 139 PluginAppletViewer.framePanel(identifier, handle, panel); 140 141 panel.init(); 142 143 // Start the applet 144 initEventQueue(panel); 138 // Framing the panel needs to happen in a thread whose thread group 139 // is the same as the threadgroup of the applet thread. If this 140 // isn't the case, the awt eventqueue thread's context classloader 141 // won't be set to a JNLPClassLoader, and when an applet class needs 142 // to be loaded from the awt eventqueue, it won't be found. 143 Thread panelInit = new Thread(panel.getThreadGroup(), new Runnable() { 144 @Override public void run() { 145 panel.createNewAppContext(); 146 // create the frame. 147 PluginAppletViewer.framePanel(identifier, handle, panel); 148 panel.init(); 149 // Start the applet 150 initEventQueue(panel); 151 } 152 }, "NetXPanel initializer"); 153 154 panelInit.start(); 155 while(panelInit.isAlive()) { 156 try { 157 panelInit.join(); 158 } catch (InterruptedException e) { 159 } 160 } 145 161 146 162 // Wait for the panel to initialize … … 221 237 String[] events = eventList.split(","); 222 238 223 for ( int i = 0; i < events.length; i++) {224 PluginDebug.debug("Adding event to queue: ", event s[i]);225 if ( events[i].equals("dispose"))239 for (String event : events) { 240 PluginDebug.debug("Adding event to queue: ", event); 241 if ("dispose".equals(event)) 226 242 panel.sendEvent(AppletPanel.APPLET_DISPOSE); 227 else if ( events[i].equals("load"))243 else if ("load".equals(event)) 228 244 panel.sendEvent(AppletPanel.APPLET_LOAD); 229 else if ( events[i].equals("init"))245 else if ("init".equals(event)) 230 246 panel.sendEvent(AppletPanel.APPLET_INIT); 231 else if ( events[i].equals("start"))247 else if ("start".equals(event)) 232 248 panel.sendEvent(AppletPanel.APPLET_START); 233 else if ( events[i].equals("stop"))249 else if ("stop".equals(event)) 234 250 panel.sendEvent(AppletPanel.APPLET_STOP); 235 else if ( events[i].equals("destroy"))251 else if ("destroy".equals(event)) 236 252 panel.sendEvent(AppletPanel.APPLET_DESTROY); 237 else if ( events[i].equals("quit"))253 else if ("quit".equals(event)) 238 254 panel.sendEvent(AppletPanel.APPLET_QUIT); 239 else if ( events[i].equals("error"))255 else if ("error".equals(event)) 240 256 panel.sendEvent(AppletPanel.APPLET_ERROR); 241 257 else 242 258 // non-fatal error if we get an unrecognized event 243 PluginDebug.debug("Unrecognized event name: ", event s[i]);259 PluginDebug.debug("Unrecognized event name: ", event); 244 260 } 245 261 … … 1609 1625 appletShutdown(p); 1610 1626 appletPanels.removeElement(p); 1627 1628 // Mark classloader unusable 1629 ((JNLPClassLoader) cl).decrementLoaderUseCount(); 1611 1630 1612 1631 try { … … 1904 1923 String att = t.get("name"); 1905 1924 1906 if (atts.containsKey(att))1907 continue;1908 1909 1925 if (att == null) { 1910 1926 statusMsgStream.println(requiresNameWarning); -
trunk/icedtea-web/plugin/icedteanp/java/sun/applet/PluginCallRequest.java
r348 r418 38 38 package sun.applet; 39 39 40 // FIXME: for each type of request extend a new (anonymous?)41 // PluginCallRequest.42 40 public abstract class PluginCallRequest { 43 41 private String message; -
trunk/icedtea-web/plugin/icedteanp/java/sun/applet/PluginCallRequestFactory.java
r348 r418 1 /* VoidPluginCallRequest -- represent Java-to-JavaScript requests 1 /* PluginCallRequestFactory -- contains factory methods for dispatching 2 an appropriate PluginCallRequest. 2 3 Copyright (C) 2008 Red Hat 3 4 … … 42 43 public PluginCallRequest getPluginCallRequest(String id, String message, Long reference) { 43 44 44 if ( id == "member") {45 if ("member".equals(id)) { 45 46 return new GetMemberPluginCallRequest(message, reference); 46 } else if ( id == "void") {47 } else if ("void".equals(id)) { 47 48 return new VoidPluginCallRequest(message, reference); 48 } else if ( id == "window") {49 } else if ("window".equals(id)) { 49 50 return new GetWindowPluginCallRequest(message, reference); 50 } else if ( id == "proxyinfo") {51 } else if ("proxyinfo".equals(id)) { 51 52 return new PluginProxyInfoRequest(message, reference); 52 } else if ( id == "cookieinfo") {53 } else if ("cookieinfo".equals(id)) { 53 54 return new PluginCookieInfoRequest(message, reference); 54 55 } else { -
trunk/icedtea-web/plugin/icedteanp/java/sun/applet/PluginCookieManager.java
r348 r418 46 46 import java.util.Map; 47 47 48 import com.sun.jndi.toolkit.url.UrlUtil; 49 48 50 public class PluginCookieManager extends CookieManager { 51 private PluginStreamHandler streamHandler; 52 53 public PluginCookieManager(PluginStreamHandler streamHandler) { 54 this.streamHandler = streamHandler; 55 } 56 57 @Override 49 58 public Map<String, List<String>> get(URI uri, 50 59 Map<String, List<String>> requestHeaders) throws IOException { … … 85 94 return false; 86 95 } 96 97 @Override 98 public void put(URI uri, 99 Map<String, List<String>> responseHeaders) throws IOException { 100 super.put(uri, responseHeaders); 101 102 for (Map.Entry<String, List<String>> headerEntry : responseHeaders.entrySet()) { 103 String type = headerEntry.getKey(); 104 if ("Set-Cookie".equalsIgnoreCase(type) || "Set-Cookie2".equalsIgnoreCase(type)) { 105 List<String> cookies = headerEntry.getValue(); 106 for (String cookie : cookies) { 107 streamHandler.write("plugin PluginSetCookie reference -1 " + UrlUtil.encode(uri.toString(), "UTF-8") + " " + cookie); 108 } 109 } 110 111 } 112 } 87 113 } -
trunk/icedtea-web/plugin/icedteanp/java/sun/applet/PluginException.java
r348 r418 1 /* VoidPluginCallRequest -- represent Java-to-JavaScript requests1 /* PluginException -- represents an exception in handling a plugin message 2 2 Copyright (C) 2008 Red Hat 3 3 -
trunk/icedtea-web/plugin/icedteanp/java/sun/applet/PluginMain.java
r368 r418 115 115 // Streams set. Start processing. 116 116 streamHandler.startProcessing(); 117 118 setCookieHandler(streamHandler); 119 117 120 } catch (Exception e) { 118 121 e.printStackTrace(); … … 185 188 // override the proxy selector set by JNLPRuntime 186 189 ProxySelector.setDefault(new PluginProxySelector()); 190 } 187 191 188 CookieManager ckManager = new PluginCookieManager(); 192 private static void setCookieHandler(PluginStreamHandler streamHandler) { 193 CookieManager ckManager = new PluginCookieManager(streamHandler); 189 194 CookieHandler.setDefault(ckManager); 190 195 } -
trunk/icedtea-web/plugin/icedteanp/java/sun/applet/PluginMessageHandlerWorker.java
r348 r418 1 /* VoidPluginCallRequest -- represent Java-to-JavaScript requests1 /* PluginMessageHandlerWorker -- worker thread for handling messages 2 2 Copyright (C) 2008 Red Hat 3 3 -
trunk/icedtea-web/plugin/icedteanp/java/sun/applet/PluginStreamHandler.java
r348 r418 60 60 61 61 private PluginMessageConsumer consumer; 62 private Boolean shuttingDown = false;62 private volatile boolean shuttingDown = false; 63 63 64 64 … … 323 323 324 324 if (message == null || message.equals("shutdown")) { 325 synchronized (shuttingDown) { 326 shuttingDown = true; 327 } 325 shuttingDown = true; 328 326 try { 329 327 // Close input/output channels to plugin. … … 363 361 // if we are shutting down, ignore write failures as 364 362 // pipe may have closed 365 synchronized (shuttingDown) { 366 if (!shuttingDown) { 367 e.printStackTrace(); 368 } 363 if (!shuttingDown) { 364 e.printStackTrace(); 369 365 } 370 366
Note:
See TracChangeset
for help on using the changeset viewer.
