misc
This commit is contained in:
parent
7f9a052480
commit
54cdabc296
@ -36,11 +36,12 @@ public class CredentialManager {
|
||||
}
|
||||
|
||||
public PasswordAuthentication getCredentialForHost(String host) {
|
||||
System.out.println("Getting cred for "+host);
|
||||
PasswordAuthentication pauth = savedCredentials.get(host);
|
||||
if (pauth == null) {
|
||||
return cachedCredentials.get(host);
|
||||
}
|
||||
return null;
|
||||
return pauth;
|
||||
}
|
||||
|
||||
public PasswordAuthentication getCredentialForProxy() {
|
||||
|
@ -9,6 +9,9 @@ public class Main {
|
||||
System.setProperty("sun.net.http.errorstream.enableBuffering", "false");
|
||||
System.setProperty("awt.useSystemAAFontSettings", "lcd");
|
||||
System.setProperty("swing.aatext", "true");
|
||||
System.setProperty("sun.java2d.d3d", "false");
|
||||
System.setProperty("sun.java2d.opengl", "false");
|
||||
System.setProperty("sun.java2d.xrender", "false");
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
|
@ -9,7 +9,6 @@ import java.util.Iterator;
|
||||
import xdman.XDMConstants;
|
||||
import xdman.downloaders.AbstractChannel;
|
||||
import xdman.downloaders.Segment;
|
||||
import xdman.downloaders.metadata.HttpMetadata;
|
||||
import xdman.network.ProxyResolver;
|
||||
import xdman.network.http.HeaderCollection;
|
||||
import xdman.network.http.HttpClient;
|
||||
@ -166,7 +165,7 @@ public class HttpChannel extends AbstractChannel {
|
||||
if (javaClientRequired) {
|
||||
Logger.log("asking for password");
|
||||
boolean proxy = code == 407;
|
||||
if (!chunk.promptCredential(hc.getHost(), proxy)) {
|
||||
if (!chunk.promptCredential(getHostName(hc.getHost()), proxy)) {
|
||||
errorCode = XDMConstants.ERR_INVALID_RESP;
|
||||
closeImpl();
|
||||
return false;
|
||||
@ -175,6 +174,7 @@ public class HttpChannel extends AbstractChannel {
|
||||
throw new JavaClientRequiredException();
|
||||
}
|
||||
|
||||
|
||||
if ("T1".equals(chunk.getTag()) || "T2".equals(chunk.getTag())) {
|
||||
if ("text/plain".equals(hc.getResponseHeader("content-type"))) {
|
||||
ByteArrayOutputStream bout = new ByteArrayOutputStream();
|
||||
@ -315,5 +315,10 @@ public class HttpChannel extends AbstractChannel {
|
||||
public String getHeader(String name) {
|
||||
return hc.getResponseHeader(name);
|
||||
}
|
||||
|
||||
private String getHostName(String hostPort) {
|
||||
return hostPort.split(":")[0];
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
@ -96,7 +96,7 @@ public class TrayHandler {
|
||||
addUrlItem.setFont(FontResource.getBigFont());
|
||||
addUrlItem.addActionListener(act);
|
||||
addUrlItem.setName("ADD_URL");
|
||||
MenuItem addVidItem = new MenuItem(StringResource.get("TITLE_DOWN_VID"));
|
||||
MenuItem addVidItem = new MenuItem(StringResource.get("MENU_VIDEO_DWN"));
|
||||
addVidItem.setFont(FontResource.getBigFont());
|
||||
addVidItem.addActionListener(act);
|
||||
addVidItem.setName("ADD_VID");
|
||||
|
@ -97,14 +97,20 @@ public class NetUtils {
|
||||
try {
|
||||
if (header == null)
|
||||
return null;
|
||||
header = header.toLowerCase();
|
||||
if (header.startsWith("attachment") || header.startsWith("inline")) {
|
||||
String headerLow = header.toLowerCase();
|
||||
if (headerLow.startsWith("attachment") || headerLow.startsWith("inline")) {
|
||||
String arr[] = header.split(";");
|
||||
for (int i = 0; i < arr.length; i++) {
|
||||
String str = arr[i].trim();
|
||||
if (str.toLowerCase().startsWith("filename")) {
|
||||
int index = str.indexOf('=');
|
||||
return str.substring(index + 1).replace("\"", "").trim();
|
||||
String file = str.substring(index + 1).replace("\"", "").trim();
|
||||
try {
|
||||
return XDMUtils.decodeFileName(file);
|
||||
} catch (Exception e) {
|
||||
return file;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -8,40 +8,32 @@ import xdman.XDMApp;
|
||||
import xdman.network.http.JavaHttpClient;
|
||||
|
||||
public class UpdateChecker {
|
||||
private static final String APP_UPDAT_URL = "http://xdman.sourceforge.net/update/update_check.php",
|
||||
private static final String SF_APP_UPDAT_URL = "http://xdman.sourceforge.net/update/update_check.php",
|
||||
GH_APP_UPDAT_URL = "https://subhra74.github.com/xdm/update/update_check.php",
|
||||
COMPONENTS_UPDATE_URL = "http://xdman.sourceforge.net/components/update_check.php";
|
||||
|
||||
public static final int APP_UPDATE_AVAILABLE = 10, COMP_UPDATE_AVAILABLE = 20, COMP_NOT_INSTALLED = 30,
|
||||
NO_UPDATE_AVAILABLE = 40;
|
||||
|
||||
public static int getUpdateStat() {
|
||||
|
||||
int stat = isComponentUpdateAvailable();
|
||||
System.out.println("Stat: " + stat);
|
||||
if (stat == 0) {
|
||||
return COMP_UPDATE_AVAILABLE;
|
||||
} else if (stat == -1) {
|
||||
return COMP_NOT_INSTALLED;
|
||||
} else {
|
||||
System.out.println("checking for app update");
|
||||
if (isAppUpdateAvailable())
|
||||
return APP_UPDATE_AVAILABLE;
|
||||
return NO_UPDATE_AVAILABLE;
|
||||
}
|
||||
if (isAppUpdateAvailable())
|
||||
return APP_UPDATE_AVAILABLE;
|
||||
return NO_UPDATE_AVAILABLE;
|
||||
}
|
||||
|
||||
private static boolean isAppUpdateAvailable() {
|
||||
return isUpdateAvailable(true, XDMApp.APP_VERSION);
|
||||
return isUpdateAvailable(XDMApp.APP_VERSION);
|
||||
}
|
||||
|
||||
// return 1 is no update required
|
||||
// return 0, -1 if update required
|
||||
private static int isComponentUpdateAvailable() {
|
||||
String componentVersion = getComponentVersion();
|
||||
System.out.println("current component version: " + componentVersion);
|
||||
if (componentVersion == null)
|
||||
return -1;
|
||||
return isUpdateAvailable(false, componentVersion) ? 0 : 1;
|
||||
}
|
||||
// private static int isComponentUpdateAvailable() {
|
||||
// String componentVersion = getComponentVersion();
|
||||
// System.out.println("current component version: " + componentVersion);
|
||||
// if (componentVersion == null)
|
||||
// return -1;
|
||||
// return isUpdateAvailable(false, componentVersion) ? 0 : 1;
|
||||
// }
|
||||
|
||||
public static String getComponentVersion() {
|
||||
File f = new File(Config.getInstance().getDataFolder());
|
||||
@ -74,10 +66,10 @@ public class UpdateChecker {
|
||||
return files[0].split("\\.")[0];
|
||||
}
|
||||
|
||||
private static boolean isUpdateAvailable(boolean app, String version) {
|
||||
private static boolean isUpdateAvailable(String version) {
|
||||
JavaHttpClient client = null;
|
||||
try {
|
||||
client = new JavaHttpClient((app ? APP_UPDAT_URL : COMPONENTS_UPDATE_URL) + "?ver=" + version);
|
||||
client = new JavaHttpClient( SF_APP_UPDAT_URL + "?ver=" + version);
|
||||
client.setFollowRedirect(true);
|
||||
client.connect();
|
||||
int resp = client.getStatusCode();
|
||||
@ -95,4 +87,11 @@ public class UpdateChecker {
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private static boolean checkAppUpdate(String version) {
|
||||
String[] urls = { GH_APP_UPDAT_URL, SF_APP_UPDAT_URL };
|
||||
while (true) {
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user