aboutsummaryrefslogtreecommitdiffstats
path: root/plugin/icedteanp/IcedTeaNPPlugin.cc
diff options
context:
space:
mode:
authorAdam Domurad <[email protected]>2012-08-09 17:59:43 -0400
committerAdam Domurad <[email protected]>2012-08-09 17:59:43 -0400
commit70c595b95417650a185108f36eaecc22ffdef958 (patch)
treeeceecb7b5ac96ae055cb72c4fb8f5ae7db77e1ce /plugin/icedteanp/IcedTeaNPPlugin.cc
parentc884698780aca57d82bc5ea557679c8c24f4cc80 (diff)
Refactor consume_message with helper consume_plugin_message
Diffstat (limited to 'plugin/icedteanp/IcedTeaNPPlugin.cc')
-rw-r--r--plugin/icedteanp/IcedTeaNPPlugin.cc123
1 files changed, 64 insertions, 59 deletions
diff --git a/plugin/icedteanp/IcedTeaNPPlugin.cc b/plugin/icedteanp/IcedTeaNPPlugin.cc
index 6c6b87f..b9fb2c4 100644
--- a/plugin/icedteanp/IcedTeaNPPlugin.cc
+++ b/plugin/icedteanp/IcedTeaNPPlugin.cc
@@ -1189,6 +1189,69 @@ plugin_in_pipe_callback (GIOChannel* source,
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 @@ void consume_message(gchar* message) {
}
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
{