Beispiel #1
0
        public static void GetFirmwareDetails(FirmFinder form, string url, ref RomDetailsClass romDetails, int DetailsKind)
        {
            string VersionID = GetVersionID(url);

            if (DetailsKind == 0 || DetailsKind == 2)
            {
                romDetails.ApprovedForInstall = ApprovedForInstallation(VersionID);
                if (romDetails.ApprovedForInstall)
                {
                    romDetails.FirmName = StaticFirmName;
                }
            }


            if (DetailsKind == 0)
            {
                return;
            }

            Progress progress   = null;
            bool     Finished   = false;
            Thread   thisthread = Thread.CurrentThread;

            form.Invoke(new Action(() =>
            {
                progress              = new Progress("Getting Package URL");
                progress.FormClosing += delegate
                {
                    if (!Finished)
                    {
                        thisthread.Abort();
                    }
                };
                progress.Show(form);
            }));

            SetProgress(form, progress, 5);
            string Package = GetPackageURL(url);

            SetProgress(form, progress, 30, "Initial Request To ZIP");
            HTTPStream httpstream = new HTTPStream(Package);

            ZipInputStream stream = new ZipInputStream(httpstream);

            SetProgress(form, progress, 40, "Exploring ZIP File...");
            int count = 0;

            while (true)
            {
                ZipEntry entry = stream.GetNextEntry();
                if (entry != null)
                {
                    count += 2;
                    if (count > 60)
                    {
                        count = 30;
                    }
                    SetProgress(form, progress, 40 + count, entry.Name);
                    if (entry.Name.Contains("SOFTWARE_VER_LIST.mbn"))
                    {
                        int    read    = 4096;
                        byte[] buffer  = new byte[read];
                        string content = "";
                        while ((read = stream.Read(buffer, 0, buffer.Length)) > 0)
                        {
                            content += Encoding.UTF8.GetString(buffer, 0, read);
                        }
                        romDetails.SupportedVersions = content.Split('\n');
                        break;
                    }
                    else
                    {
                        stream.CloseEntry();
                    }
                }
                else
                {
                    MessageBox.Show("Seems like I couldn't load the data :(", "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    break;
                }
            }
            Finished = true;
            progress.Close();
        }