From ffd8d59e4b9c5bbb04a5e6825f46b181a754f3a2 Mon Sep 17 00:00:00 2001 From: "honfika@gmail.com" Date: Sun, 3 Apr 2016 22:15:30 +0200 Subject: [PATCH] build fix --- .../flash/configuration/Configuration.java | 32 +----------------- .../src/com/jpexs/helpers/Helper.java | 33 ++++++++++++++++++- 2 files changed, 33 insertions(+), 32 deletions(-) diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/configuration/Configuration.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/configuration/Configuration.java index 3c684c7eb..fc5f1877a 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/configuration/Configuration.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/configuration/Configuration.java @@ -21,7 +21,6 @@ import com.jpexs.decompiler.flash.exporters.modes.ExeExportMode; import com.jpexs.decompiler.flash.helpers.CodeFormatting; import com.jpexs.decompiler.flash.importers.TextImportResizeTextBoundsMode; import com.jpexs.helpers.Helper; -import com.jpexs.helpers.utf8.Utf8Helper; import java.io.BufferedOutputStream; import java.io.File; import java.io.FileInputStream; @@ -34,10 +33,6 @@ import java.lang.reflect.Field; import java.lang.reflect.Modifier; import java.lang.reflect.ParameterizedType; import java.lang.reflect.Type; -import java.net.InetSocketAddress; -import java.net.Proxy; -import java.net.URL; -import java.net.URLConnection; import java.security.AccessController; import java.security.PrivilegedAction; import java.util.ArrayList; @@ -941,33 +936,8 @@ public class Configuration { return getPath("projector"); } - private static byte[] downloadsUrl(String urlString) throws IOException { - String proxyAddress = Configuration.updateProxyAddress.get(); - URL url = new URL(urlString); - - URLConnection uc; - if (proxyAddress != null && !proxyAddress.isEmpty()) { - int port = 8080; - if (proxyAddress.contains(":")) { - String[] parts = proxyAddress.split(":"); - port = Integer.parseInt(parts[1]); - proxyAddress = parts[0]; - } - - uc = url.openConnection(new Proxy(Proxy.Type.HTTP, new InetSocketAddress(proxyAddress, port))); - } else { - uc = url.openConnection(); - } - uc.setRequestProperty("User-Agent", ApplicationInfo.shortApplicationVerName); - - uc.connect(); - - return Helper.readStream(uc.getInputStream()); - } - private static String getDownloadsHtml() throws IOException { - byte[] data = downloadsUrl("https://www.adobe.com/support/flashplayer/downloads.html"); - String html = new String(data, Utf8Helper.charset); + String html = Helper.downloadUrlString("https://www.adobe.com/support/flashplayer/downloads.html"); return html; } diff --git a/libsrc/ffdec_lib/src/com/jpexs/helpers/Helper.java b/libsrc/ffdec_lib/src/com/jpexs/helpers/Helper.java index c260936c0..791627f88 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/helpers/Helper.java +++ b/libsrc/ffdec_lib/src/com/jpexs/helpers/Helper.java @@ -17,6 +17,7 @@ package com.jpexs.helpers; import com.jpexs.decompiler.flash.AppResources; +import com.jpexs.decompiler.flash.ApplicationInfo; import com.jpexs.decompiler.flash.configuration.Configuration; import com.jpexs.decompiler.flash.helpers.Freed; import com.jpexs.decompiler.flash.helpers.GraphTextWriter; @@ -43,6 +44,10 @@ import java.io.ObjectOutputStream; import java.io.OutputStream; import java.lang.reflect.Field; import java.lang.reflect.Modifier; +import java.net.InetSocketAddress; +import java.net.Proxy; +import java.net.URL; +import java.net.URLConnection; import java.text.MessageFormat; import java.util.ArrayList; import java.util.Arrays; @@ -1446,7 +1451,33 @@ public class Helper { || wow64Arch != null && wow64Arch.endsWith("64"); } - public static void showOutOfMemoryWarning() { + public static byte[] downloadUrl(String urlString) throws IOException { + String proxyAddress = Configuration.updateProxyAddress.get(); + URL url = new URL(urlString); + URLConnection uc; + if (proxyAddress != null && !proxyAddress.isEmpty()) { + int port = 8080; + if (proxyAddress.contains(":")) { + String[] parts = proxyAddress.split(":"); + port = Integer.parseInt(parts[1]); + proxyAddress = parts[0]; + } + + uc = url.openConnection(new Proxy(Proxy.Type.HTTP, new InetSocketAddress(proxyAddress, port))); + } else { + uc = url.openConnection(); + } + uc.setRequestProperty("User-Agent", ApplicationInfo.shortApplicationVerName); + + uc.connect(); + + return Helper.readStream(uc.getInputStream()); + } + + public static String downloadUrlString(String url) throws IOException { + byte[] data = downloadUrl(url); + String text = new String(data, Utf8Helper.charset); + return text; } }