Exemplo n.º 1
0
        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);
        }
Exemplo n.º 2
0
        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");
            }
        }
Exemplo n.º 3
0
        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);
            }
        }
Exemplo n.º 4
0
        public static YLS Import(String wat)
        {
            if (!File.Exists(wat))
            {
                return(null);
            }
            YLS       yls  = new YLS();
            YLS_Title titl = null;

            String[] line = null;
            using (StreamReader str = File.OpenText(wat))
            {
                str.ReadLine();

                while (!str.EndOfStream)
                {
                    line = str.ReadLine().Split(',');
                    if (line.Length != 4)
                    {
                        continue;
                    }

                    titl = new YLS_Title();

                    titl.id = Convert.ToUInt64(line[0], 16);

                    if (titl.id == 0x4013000001B02)
                    {
                        line[3] = line[3].Replace("02-11-15 GPIO", "9.5.0-22");
                    }
                    if (titl.id == 0x400102002CA00)
                    {
                        line[3] = line[3].Replace("10-02-14 JPN", "9.1.0-20J");
                    }

                    Match mat = Regex.Match(line[3], @"(\d+)\.(\d+)\.(\d+)-(\d+)");

                    foreach (String ver in line[2].Split(' '))
                    {
                        while (mat.Success && String.IsNullOrEmpty(mat.ToString()))
                        {
                            mat = mat.NextMatch();                                                        //stupid dotNOT Regex engine ¬_¬
                        }
                        if (!mat.Success)
                        {
                            throw new InvalidDataException("Invalid report file!");
                        }

                        titl.ver.Add(new YLS_Titlever()
                        {
                            version = int.Parse(ver.Substring(1)), sysver = new YLS_Sysver()
                            {
                                label = mat.ToString()
                            }
                        });

                        mat = mat.NextMatch();
                    }

                    if (mat != null && mat.Success)
                    {
                        throw new InvalidDataException("Invalid report file!");
                    }
                    else
                    {
                        yls.Entry(line[1][0], titl);
                    }
                }
            }
            return(yls);
        }