private bool readRepository(string url) { System.Net.ServicePointManager.ServerCertificateValidationCallback += (s, ce, ca, p) => true; // or you get an exeption, because mono doesnt trust anyone //normalize it if (!url.StartsWith("https://raw.github.com/")) { Uri urlNorm = new Uri(url); url = urlNorm.Host; } String repoinfo = null; try { WebClientTimeOut client = new WebClientTimeOut(); if (url.StartsWith("https://raw.github.com/")) { repoinfo = client.DownloadString(new Uri(url + "/repoinfo.txt")); } else { repoinfo = client.DownloadString(new Uri("http://" + url + "/repoinfo")); } } catch (WebException ex) { Console.WriteLine(ex); return(false); } RepoInfoMessage message = null; try { JsonReader reader = new JsonReader(); message = reader.Read(repoinfo, typeof(RepoInfoMessage)) as RepoInfoMessage; } catch { return(false); } if (message == null) { return(false); } if (!message.msg.Equals("success")) { return(false); } Repo repo = message.data; repo.tryToGetFavicon(); repositories.Add(repo); return(this.tryToFetchModList(repo)); }
public bool tryToFetchModList(Repo repo) { String modlist = null; try { WebClientTimeOut client = new WebClientTimeOut(); if (repo.url.StartsWith("https://raw.github.com/")) { modlist = client.DownloadString(new Uri(repo.url + "modlist.txt")); } else { modlist = client.DownloadString(new Uri(repo.url + "modlist")); } } catch (WebException ex) { Console.WriteLine(ex); repositories.Remove(repo); return(false); } ModListMessage message = null; try { JsonReader reader = new JsonReader(); message = reader.Read(modlist, typeof(ModListMessage)) as ModListMessage; } catch { repositories.Remove(repo); return(false); } if (message == null) { repositories.Remove(repo); return(false); } if (!message.msg.Equals("success")) { repositories.Remove(repo); return(false); } modsPerRepo.Add(repo, new List <Item>(message.data)); return(true); }
public static bool tryUpdate() { WebClientTimeOut client = new WebClientTimeOut (); String versionMessageRaw; try { versionMessageRaw = client.DownloadString (new Uri("http://mods.scrollsguide.com/version")); } catch (WebException) { return false; } JsonReader reader = new JsonReader (); VersionMessage versionMessage = (VersionMessage)reader.Read (versionMessageRaw, typeof(VersionMessage)); int version = versionMessage.version (); String installPath = Platform.getGlobalScrollsInstallPath () + Path.DirectorySeparatorChar + "ModLoader" + Path.DirectorySeparatorChar; try { File.Delete (installPath + "Updater.exe"); } catch {} if (!System.IO.Directory.Exists(installPath)) { System.IO.Directory.CreateDirectory(installPath); } if (version > ModLoader.getVersion()) { byte[] asm; try { asm = client.DownloadData(new Uri("http://mods.scrollsguide.com/download/update")); } catch (WebException) { return false; } File.WriteAllBytes (installPath + "Updater.exe", asm); if (CheckToken (installPath + "Updater.exe", token)) { try { App.Popups.ShowInfo ("Scrolls Summoner is updating", "Please wait while the update is being downloaded"); Dialogs.showNotification("Scrolls Summoner is updating", "Please wait while the update is being downloaded"); } catch { } if (Platform.getOS () == Platform.OS.Win) { new Process { StartInfo = { FileName = installPath + "Updater.exe", Arguments = "" } }.Start (); } else if (Platform.getOS () == Platform.OS.Mac) { Assembly.LoadFrom (installPath + "Updater.exe").EntryPoint.Invoke (null, new object[] { new string[] {} }); } return true; } try { App.Popups.KillCurrentPopup(); } catch {} } return false; }
private bool readRepository(string url) { //normalize it Uri urlNorm = new Uri(url); url = urlNorm.Host; String repoinfo = null; try { WebClientTimeOut client = new WebClientTimeOut(); repoinfo = client.DownloadString(new Uri("http://" + url + "/repoinfo")); } catch (WebException ex) { Console.WriteLine(ex); return(false); } RepoInfoMessage message = null; try { JsonReader reader = new JsonReader(); message = reader.Read(repoinfo, typeof(RepoInfoMessage)) as RepoInfoMessage; } catch { return(false); } if (message == null) { return(false); } if (!message.msg.Equals("success")) { return(false); } Repo repo = message.data; repo.tryToGetFavicon(); repositories.Add(repo); return(this.tryToFetchModList(repo)); }
private bool readRepository(string url) { //normalize it Uri urlNorm = new Uri (url); url = urlNorm.Host; String repoinfo = null; try { WebClientTimeOut client = new WebClientTimeOut (); repoinfo = client.DownloadString (new Uri("http://"+url+"/repoinfo")); } catch (WebException ex) { Console.WriteLine (ex); return false; } RepoInfoMessage message = null; try { JsonReader reader = new JsonReader(); message = reader.Read(repoinfo, typeof(RepoInfoMessage)) as RepoInfoMessage; } catch { return false; } if (message == null) { return false; } if (!message.msg.Equals("success")) { return false; } Repo repo = message.data; repo.tryToGetFavicon (); repositories.Add(repo); return this.tryToFetchModList (repo); }
public bool tryToFetchModList(Repo repo) { String modlist = null; try { WebClientTimeOut client = new WebClientTimeOut (); modlist = client.DownloadString (new Uri(repo.url+"modlist")); } catch (WebException ex) { Console.WriteLine (ex); repositories.Remove (repo); return false; } ModListMessage message = null; try { JsonReader reader = new JsonReader(); message = reader.Read(modlist, typeof(ModListMessage)) as ModListMessage; } catch { repositories.Remove (repo); return false; } if (message == null) { repositories.Remove (repo); return false; } if (!message.msg.Equals("success")) { repositories.Remove (repo); return false; } modsPerRepo.Add (repo, new List<Item>(message.data)); return true; }
private static byte[] token = new byte[] { 8, 95, 174, 161, 22, 41, 180, 133 }; //public key public static bool tryUpdate() { WebClientTimeOut client = new WebClientTimeOut(); String versionMessageRaw; try { versionMessageRaw = client.DownloadString(new Uri("http://mods.scrollsguide.com/version")); } catch (WebException) { return(false); } JsonReader reader = new JsonReader(); VersionMessage versionMessage = (VersionMessage)reader.Read(versionMessageRaw, typeof(VersionMessage)); int version = versionMessage.version(); String installPath = Platform.getModLoaderPath() + Path.DirectorySeparatorChar; //;Platform.getGlobalScrollsInstallPath () + Path.DirectorySeparatorChar + "ModLoader" + Path.DirectorySeparatorChar; try { File.Delete(installPath + "Updater.exe"); } catch {} if (!System.IO.Directory.Exists(installPath)) { System.IO.Directory.CreateDirectory(installPath); } if (version > ModLoader.getVersion()) { byte[] asm; try { asm = client.DownloadData(new Uri("http://mods.scrollsguide.com/download/update")); } catch (WebException) { return(false); } File.WriteAllBytes(installPath + "Updater.exe", asm); if (CheckToken(installPath + "Updater.exe", token)) { try { App.Popups.ShowInfo("Scrolls Summoner is updating", "Please wait while the update is being downloaded"); Dialogs.showNotification("Scrolls Summoner is updating", "Please wait while the update is being downloaded"); } catch { } if (Platform.getOS() == Platform.OS.Win) { new Process { StartInfo = { FileName = installPath + "Updater.exe", Arguments = "" } }.Start(); } else if (Platform.getOS() == Platform.OS.Mac) { Assembly.LoadFrom(installPath + "Updater.exe").EntryPoint.Invoke(null, new object[] { new string[] {} }); } return(true); } try { App.Popups.KillCurrentPopup(); } catch {} } return(false); }
private bool readRepository(string url) { System.Net.ServicePointManager.ServerCertificateValidationCallback += (s, ce, ca, p) => true;// or you get an exeption, because mono doesnt trust anyone //normalize it if (!url.StartsWith ("https://raw.github.com/")) { Uri urlNorm = new Uri (url); url = urlNorm.Host; } String repoinfo = null; try { WebClientTimeOut client = new WebClientTimeOut (); if(url.StartsWith("https://raw.github.com/")) { repoinfo = client.DownloadString (new Uri(url+"/repoinfo.txt")); } else { repoinfo = client.DownloadString (new Uri("http://"+url+"/repoinfo")); } } catch (WebException ex) { Console.WriteLine (ex); return false; } RepoInfoMessage message = null; try { JsonReader reader = new JsonReader(); message = reader.Read(repoinfo, typeof(RepoInfoMessage)) as RepoInfoMessage; } catch { return false; } if (message == null) { return false; } if (!message.msg.Equals("success")) { return false; } Repo repo = message.data; repo.tryToGetFavicon (); repositories.Add(repo); return this.tryToFetchModList (repo); }