X-Git-Url: http://git.nikiroo.be/?a=blobdiff_plain;f=src%2Fbe%2Fnikiroo%2Ffanfix%2FVersionCheck.java;h=8b2a343f3cef331a2dbc059306586d6c2eaa83b7;hb=509c7ce173c9d2f607cca22799d66ddb24a9aa29;hp=2c9a0328aca615aa982f58f68262b636e9758086;hpb=c4cefaa04ec122fc02efb6542451a31fdf722c32;p=nikiroo-utils.git diff --git a/src/be/nikiroo/fanfix/VersionCheck.java b/src/be/nikiroo/fanfix/VersionCheck.java index 2c9a032..8b2a343 100644 --- a/src/be/nikiroo/fanfix/VersionCheck.java +++ b/src/be/nikiroo/fanfix/VersionCheck.java @@ -20,7 +20,7 @@ import be.nikiroo.utils.Version; * @author niki */ public class VersionCheck { - private static final String base = "https://github.com/nikiroo/fanfix/raw/master/changelog${LANG}.md"; + private static final String base = "https://github.com/${PROJECT}/raw/master/changelog${LANG}.md"; private Version current; private List newer; @@ -93,24 +93,31 @@ public class VersionCheck { * time has elapsed. */ public void ok() { - Instance.setVersionChecked(); + Instance.getInstance().setVersionChecked(); } /** * Check if there are available {@link Version}s of this program more recent * than the current one. * + * @param githubProject + * the GitHub project to check on, for instance "nikiroo/fanfix" + * * @return a {@link VersionCheck} */ - public static VersionCheck check() { + public static VersionCheck check(String githubProject) { Version current = Version.getCurrentVersion(); List newer = new ArrayList(); Map> changes = new HashMap>(); - if (Instance.isVersionCheckNeeded()) { + if (Instance.getInstance().isVersionCheckNeeded()) { try { - // Prepare the URLs according to the user's language - Locale lang = Instance.getTrans().getLocale(); + // Use the right project: + String base = VersionCheck.base.replace("${PROJECT}", + githubProject); + + // Prepare the URLs according to the user's language: + Locale lang = Instance.getInstance().getTrans().getLocale(); String fr = lang.getLanguage(); String BE = lang.getCountry().replace(".UTF8", ""); String urlFrBE = base.replace("${LANG}", "-" + fr + "_" + BE); @@ -120,8 +127,8 @@ public class VersionCheck { InputStream in = null; for (String url : new String[] { urlFrBE, urlFr, urlDefault }) { try { - in = Instance.getCache() - .open(new URL(url), null, false); + in = Instance.getInstance().getCache().openNoCache( + new URL(url), null, null, null, null); break; } catch (IOException e) { } @@ -162,10 +169,8 @@ public class VersionCheck { reader.close(); } } catch (IOException e) { - Instance.getTraceHandler() - .error(new IOException( - "Cannot download latest changelist on github.com", - e)); + Instance.getInstance().getTraceHandler() + .error(new IOException("Cannot download latest changelist on github.com", e)); } }