private void firmwdownload(string firm, string reg) { string cd = Path.GetDirectoryName(Application.ExecutablePath); if(reg == null || reg.Length != 1 || !yls.regions.ContainsKey(reg[0])) { MessageBox.Show("Invalid region! Valid regions are:\r\n" + String.Join(", ", yls.regions.Keys.ToArray()), "Invalid region", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } //better be safe'n'paranoid if(yls == null) if(File.Exists(cd + "\\titlelist.csv")) yls = YLS.Import(cd + "\\titlelist.csv"); else { MessageBox.Show("Can't read title list, file doesn't exist.", "File not found", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } WebClient titlelist = new WebClient(); Directory.CreateDirectory(cd + "\\" + t_titleid.Text); YLS_Sysver sys = new YLS_Sysver(); sys.label = firm; foreach(YLS_Title t in yls.regions[reg[0]]) { YLS_Titlever optimal = null; foreach(YLS_Titlever tv in t.ver) { if(tv.sysver == sys) { optimal = tv; break; } if(tv.sysver < sys && (optimal == null || tv.sysver > optimal.sysver)) optimal = tv; } if(optimal == null) continue; singledownload(t.id.ToString("X16"), optimal.version.ToString()); Application.DoEvents(); } log("\r\n" + DateTime.Now + " Firmware Download complete!"); notifyIcon1.BalloonTipText = "Firmware download complete!"; notifyIcon1.ShowBalloonTip(1); }
private void materialFlatButton1_Click(object sender, EventArgs e) { b_download.Enabled = false; cancel = false; t_log.Clear(); if (working) { cancel = true; sd.stahp(); b_download.Text = "BEGIN DOWNLOAD"; b_download.Enabled = true; return; } t_titleid.Text = t_titleid.Text.Trim(); Match match = Regex.Match(t_titleid.Text, @"(\d+)\.(\d+)(\.(\d+))?(-(\d+))?([a-zA-Z])+"); if (match.Success) { if (yls == null) { log("Checking title database, please wait..."); String csvname = sysarr[selsys] + ".csv"; if (sd.syncDown(ninupdate + sysarr[selsys], csvname)) { yls = YLS.Import(csvname); } else { if (File.Exists(csvname)) { MessageBox.Show("Can't update titlelist! The current (possibly older) titlelist will be used instead.", "Can't update titlelist", MessageBoxButtons.OK, MessageBoxIcon.Error); yls = YLS.Import("titlelist.csv"); } else { MessageBox.Show("Can't acquire the title list!\r\n" + "You can still download titles, but firmware downloading is not possible, thus the downloading will be aborted.", "Can't update titlelist", MessageBoxButtons.OK, MessageBoxIcon.Error); b_download.Enabled = true; return; } } } YLS_Sysver firmw = new YLS_Sysver() { label = (match.Groups[1] + "." + match.Groups[2] + "." + (match.Groups[4].Success ? match.Groups[4].ToString() : "9") + "-" + (match.Groups[6].Success ? match.Groups[6].ToString() : "999")) }; String region = match.Groups[7].ToString().ToUpper(); t_titleid.Text = firmw + region; t_titleid.Update(); log("Downloading Firmware: " + firmw + region); b_download.Enabled = true; working = true; b_download.Text = "CANCEL"; firmwdownload(firmw, region[0]); working = false; b_download.Text = "BEGIN DOWNLOAD"; return; } match = Regex.Match(t_titleid.Text, @"(0-9a-fA-F]{16})([\s_]*v?(\d+))?"); if (match.Success) { ulong title = Convert.ToUInt64(match.Groups[1].ToString(), 16); int version = int.Parse(match.Groups[3].ToString()); b_download.Enabled = true; working = true; b_download.Text = "CANCEL"; singledownload(title, version); working = false; b_download.Text = "BEGIN DOWNLOAD"; return; } else { MessageBox.Show("Your input didn't match as a firmware version, nor as a title ID.\r\n" + "Please see the little question mark above the textbox for more help.", "Invalid input", MessageBoxButtons.OK, MessageBoxIcon.Error); } b_download.Enabled = true; }
private void materialRadioButton1_CheckedChanged(object sender, EventArgs e) { selsys = 1; yls = null; }
private void pictureBox1_Click(object sender, EventArgs e) { t_titleid.Text = t_titleid.Text.Trim(); t_version.Text = t_version.Text.Trim(); if (t_titleid.Text.Length == 0 || t_version.Text.Length == 0) { MessageBox.Show("Please enter a Firmware or Title to download;" + "Ex: 8.1.0-23 ---- USA; Or 00000000000 ---- v1024 "); return; } if (c_cia.Checked && !File.Exists("make_cdn_cia.exe")) { MessageBox.Show("Error: make_cdn_cia.exe can't be found in the working directory!\r\n" + "This option will be unavailable while make_cdn_cia.exe is not found", "File not found", MessageBoxButtons.OK, MessageBoxIcon.Error); c_cia.Checked = false; } String cd = Path.GetDirectoryName(Application.ExecutablePath); if(yls == null) if(File.Exists(cd + "\\titlelist.csv")) yls = YLS.Import(cd + "\\titlelist.csv"); else { MessageBox.Show("Can't read title list, file doesn't exist.", "File not found", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } if (t_titleid.Text.Contains(".")) { string firmw = t_titleid.Text; string reg = t_version.Text; Match match = Regex.Match(firmw, @"(\d+)\.(\d+)(\.(\d+))?(-(\d+))?([a-zA-Z])?"); if(!match.Success) { MessageBox.Show("Invalid firmware string format!"); return; } firmw = (match.Groups[1] + "." + match.Groups[2] + "." + (match.Groups[4].Success ? match.Groups[4].ToString() : "0") + "-" + (match.Groups[6].Success ? match.Groups[6].ToString() : "999")); t_titleid.Text = firmw; t_titleid.Update(); switch(reg.ToUpper()) { case "EUR": reg = "E"; break; case "USA": reg = "U"; break; case "JPN": reg = "J"; break; case "TWN": reg = "T"; break; case "CHN": reg = "C"; break; case "KOR": reg = "K"; break; } t_version.Text = reg; t_version.Update(); log(DateTime.Now + " Downloading Firmware: " + firmw + reg); notifyIcon1.BalloonTipText = "Downloading Firmware: " + firmw + reg; notifyIcon1.ShowBalloonTip(1); firmwdownload(firmw, reg); } else { string title = t_titleid.Text; string version = t_version.Text; if(version[0] == 'v') { version = version.Substring(1); t_version.Text = version; t_version.Update(); } singledownload(title, version); } }
private void SysSelectRadio_CheckedChanged(object sender, EventArgs e) { WebClient titlelist = new WebClient(); String cd = Path.GetDirectoryName(Application.ExecutablePath); yls = null; RadioButton chk = panel1.Controls.OfType<RadioButton>().FirstOrDefault(ch => ch.Checked); if(chk == null) return; switch(chk.Name) { case "radioButton1": titlelist.DownloadFile("http://yls8.mtheall.com/ninupdates/titlelist.php?sys=ktr&csv=1", cd + "\\titlelist.csv"); break; case "radioButton2": case "radioButton3": titlelist.DownloadFile("http://yls8.mtheall.com/ninupdates/titlelist.php?sys=ctr&csv=1", cd + "\\titlelist.csv"); break; default: MessageBox.Show("Well, this shouldn't be happening!\r\nDeveloper! " + "Please update Form1.cs @ SysSelectRadio_CheckedChanged!\r\n\r\nThanks! :D", "Developer error", MessageBoxButtons.OK, MessageBoxIcon.Error); break; } if(File.Exists(cd + "\\titlelist.csv")) yls = YLS.Import(cd + "\\titlelist.csv"); }