# HG changeset patch # User Adam Domurad # Date 1345218049 14400 # Node ID 5586c774341b39e1f29acfaffc0da17f89484681 # Parent 7c1698fa1dd75790f36b73078ff035b201dc472c Extract plugin message handling into consume_plugin_message diff -r 7c1698fa1dd7 -r 5586c774341b ChangeLog --- a/ChangeLog Fri Aug 17 11:39:28 2012 -0400 +++ b/ChangeLog Fri Aug 17 11:40:49 2012 -0400 @@ -1,3 +1,11 @@ +2012-08-17 Adam Domurad + + * plugin/icedteanp/IcedTeaNPPlugin.cc + (consume_plugin_message): New, called by consume_message, handles + cookie and proxy info retrieval, and setting cookie info + (consume_message): Call consume_plugin_message for "plugin ..." + messages + 2012-08-17 Adam Domurad Reproducers for PR588, sets persistent and session cookies in the diff -r 7c1698fa1dd7 -r 5586c774341b plugin/icedteanp/IcedTeaNPPlugin.cc --- a/plugin/icedteanp/IcedTeaNPPlugin.cc Fri Aug 17 11:39:28 2012 -0400 +++ b/plugin/icedteanp/IcedTeaNPPlugin.cc Fri Aug 17 11:40:49 2012 -0400 @@ -1189,6 +1189,69 @@ return keep_installed; } +static +void consume_plugin_message(gchar* message) { + // internal plugin related message + gchar** parts = g_strsplit (message, " ", 5); + if (g_str_has_prefix(parts[1], "PluginProxyInfo")) + { + gchar* proxy; + uint32_t len; + + gchar* decoded_url = (gchar*) calloc(strlen(parts[4]) + 1, sizeof(gchar)); + IcedTeaPluginUtilities::decodeURL(parts[4], &decoded_url); + 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); + + gchar* proxy_info; + +#if MOZILLA_VERSION_COLLAPSED < 1090100 + proxy = (char*) malloc(sizeof(char)*2048); +#endif + + proxy_info = g_strconcat ("plugin PluginProxyInfo reference ", parts[3], " ", NULL); + if (get_proxy_info(decoded_url, &proxy, &len) == NPERR_NO_ERROR) + { + proxy_info = g_strconcat (proxy_info, proxy, NULL); + } + + PLUGIN_DEBUG("Proxy info: %s\n", proxy_info); + plugin_send_message_to_appletviewer(proxy_info); + + free(decoded_url); + decoded_url = NULL; + g_free(proxy_info); + proxy_info = NULL; + +#if MOZILLA_VERSION_COLLAPSED < 1090100 + g_free(proxy); + proxy = NULL; +#endif + + } else if (g_str_has_prefix(parts[1], "PluginCookieInfo")) + { + gchar* decoded_url = (gchar*) calloc(strlen(parts[4])+1, sizeof(gchar)); + IcedTeaPluginUtilities::decodeURL(parts[4], &decoded_url); + + gchar* cookie_info = g_strconcat ("plugin PluginCookieInfo reference ", parts[3], " ", NULL); + gchar* cookie_string; + uint32_t len; + if (get_cookie_info(decoded_url, &cookie_string, &len) == NPERR_NO_ERROR) + { + cookie_info = g_strconcat (cookie_info, cookie_string, NULL); + } + + PLUGIN_DEBUG("Cookie info: %s\n", cookie_info); + plugin_send_message_to_appletviewer(cookie_info); + + free(decoded_url); + decoded_url = NULL; + g_free(cookie_info); + cookie_info = NULL; + } + g_strfreev (parts); + parts = NULL; +} + void consume_message(gchar* message) { PLUGIN_DEBUG (" PIPE: plugin read: %s\n", message); @@ -1251,65 +1314,7 @@ } else if (g_str_has_prefix (message, "plugin ")) { - // internal plugin related message - gchar** parts = g_strsplit (message, " ", 5); - if (g_str_has_prefix(parts[1], "PluginProxyInfo")) - { - gchar* proxy; - uint32_t len; - - gchar* decoded_url = (gchar*) calloc(strlen(parts[4]) + 1, sizeof(gchar)); - IcedTeaPluginUtilities::decodeURL(parts[4], &decoded_url); - 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); - - gchar* proxy_info; - -#if MOZILLA_VERSION_COLLAPSED < 1090100 - proxy = (char*) malloc(sizeof(char)*2048); -#endif - - proxy_info = g_strconcat ("plugin PluginProxyInfo reference ", parts[3], " ", NULL); - if (get_proxy_info(decoded_url, &proxy, &len) == NPERR_NO_ERROR) - { - proxy_info = g_strconcat (proxy_info, proxy, NULL); - } - - PLUGIN_DEBUG("Proxy info: %s\n", proxy_info); - plugin_send_message_to_appletviewer(proxy_info); - - free(decoded_url); - decoded_url = NULL; - g_free(proxy_info); - proxy_info = NULL; - -#if MOZILLA_VERSION_COLLAPSED < 1090100 - g_free(proxy); - proxy = NULL; -#endif - - } else if (g_str_has_prefix(parts[1], "PluginCookieInfo")) - { - gchar* decoded_url = (gchar*) calloc(strlen(parts[4])+1, sizeof(gchar)); - IcedTeaPluginUtilities::decodeURL(parts[4], &decoded_url); - - gchar* cookie_info = g_strconcat ("plugin PluginCookieInfo reference ", parts[3], " ", NULL); - gchar* cookie_string; - uint32_t len; - if (get_cookie_info(decoded_url, &cookie_string, &len) == NPERR_NO_ERROR) - { - cookie_info = g_strconcat (cookie_info, cookie_string, NULL); - } - - PLUGIN_DEBUG("Cookie info: %s\n", cookie_info); - plugin_send_message_to_appletviewer(cookie_info); - - free(decoded_url); - decoded_url = NULL; - g_free(cookie_info); - cookie_info = NULL; - } - g_strfreev (parts); - parts = NULL; + consume_plugin_message(message); } else {