Esempio n. 1
0
        public static Command.Firmware UpdateCheckAuto(
            string model,
            string region,
            bool BinaryNature)
        {
            int num = 0;

            Command.Firmware firmware = new Command.Firmware();
            foreach (Func <string, string, string> fwFetchFunc in FWFetch.FWFetchFuncs)
            {
                string info = fwFetchFunc(model, region);
                if (!string.IsNullOrEmpty(info))
                {
                    ++num;
                    firmware = Command.UpdateCheck(model, region, info, BinaryNature, true);
                    if (firmware.Version == null)
                    {
                        if (firmware.ConnectionError)
                        {
                            break;
                        }
                    }
                    else
                    {
                        break;
                    }
                }
            }
            if (firmware.Version == null)
            {
                Logger.WriteLog("Could not fetch info for " + model + "/" + region + ". Please verify the input or use manual info", false);
            }
            firmware.FetchAttempts = num;
            return(firmware);
        }
Esempio n. 2
0
 private void update_button_Click(object sender, EventArgs e)
 {
     if (string.IsNullOrEmpty(this.model_textbox.Text))
     {
         Logger.WriteLog("Error: Please specify a model", false);
     }
     else if (string.IsNullOrEmpty(this.region_textbox.Text))
     {
         Logger.WriteLog("Error: Please specify a region", false);
     }
     else if (this.checkbox_manual.Checked && (string.IsNullOrEmpty(this.pda_textbox.Text) || string.IsNullOrEmpty(this.csc_textbox.Text) || string.IsNullOrEmpty(this.phone_textbox.Text)))
     {
         Logger.WriteLog("Error: Please specify PDA, CSC and Phone version or use Auto Method", false);
     }
     else
     {
         BackgroundWorker backgroundWorker = new BackgroundWorker();
         backgroundWorker.DoWork += (DoWorkEventHandler)((o, _e) =>
         {
             try
             {
                 this.SetProgressBar(0);
                 this.ControlsEnabled(false);
                 Utility.ReconnectDownload = false;
                 this.FW = !this.checkbox_auto.Checked ? Command.UpdateCheck(this.model_textbox.Text, this.region_textbox.Text, this.pda_textbox.Text, this.csc_textbox.Text, this.phone_textbox.Text, this.pda_textbox.Text, this.binary_checkbox.Checked, false) : Command.UpdateCheckAuto(this.model_textbox.Text, this.region_textbox.Text, this.binary_checkbox.Checked);
                 if (!string.IsNullOrEmpty(this.FW.Filename))
                 {
                     this.file_textbox.Invoke((Delegate)((Action)(() => this.file_textbox.Text = this.FW.Filename)));
                     this.version_textbox.Invoke((Delegate)((Action)(() => this.version_textbox.Text = this.FW.Version)));
                     this.size_textbox.Invoke((Delegate)((Action)(() => this.size_textbox.Text = (long.Parse(this.FW.Size) / 1024L / 1024L).ToString() + " MB")));
                 }
                 else
                 {
                     this.file_textbox.Invoke((Delegate)((Action)(() => this.file_textbox.Text = string.Empty)));
                     this.version_textbox.Invoke((Delegate)((Action)(() => this.version_textbox.Text = string.Empty)));
                     this.size_textbox.Invoke((Delegate)((Action)(() => this.size_textbox.Text = string.Empty)));
                 }
                 this.ControlsEnabled(true);
             }
             catch (Exception ex)
             {
                 Logger.WriteLog(ex.Message, false);
                 Logger.WriteLog(ex.ToString(), false);
             }
         });
         backgroundWorker.RunWorkerAsync();
     }
 }
Esempio n. 3
0
 private static void SaveMeta(Command.Firmware fw)
 {
     if (fw.Version == null || string.IsNullOrEmpty(CmdLine.fwdest))
     {
         return;
     }
     if (!string.IsNullOrEmpty(Path.GetDirectoryName(CmdLine.metafile)) && !Directory.Exists(Path.GetDirectoryName(CmdLine.metafile)))
     {
         Directory.CreateDirectory(Path.GetDirectoryName(CmdLine.metafile));
     }
     using (TextWriter text = (TextWriter)File.CreateText(CmdLine.metafile))
     {
         text.WriteLine("[hadesFirmData]");
         text.WriteLine("Model=" + fw.Model);
         text.WriteLine("Devicename=" + fw.DisplayName);
         text.WriteLine("Region=" + fw.Region);
         text.WriteLine("Version=" + fw.Version);
         text.WriteLine("OS=" + fw.OS);
         text.WriteLine("Filesize=" + (object)new FileInfo(CmdLine.fwdest).Length);
         text.WriteLine("Filename=" + CmdLine.fwdest);
         text.WriteLine("LastModified=" + fw.LastModified);
     }
 }
Esempio n. 4
0
        public static Command.Firmware UpdateCheck(
            string model,
            string region,
            string pda,
            string csc,
            string phone,
            string data,
            bool BinaryNature,
            bool AutoFetch = false)
        {
            Command.Firmware firmware = new Command.Firmware();
            Logger.WriteLog("Checking firmware for " + model + "/" + region + "/" + pda + "/" + csc + "/" + phone + "/" + data, false);
            int nonce = Web.GenerateNonce();

            if (nonce != 200)
            {
                Logger.WriteLog("Error: Could not generate Nonce. Status code " + (object)nonce, false);
                firmware.ConnectionError = true;
                return(firmware);
            }
            string xmlresponse;
            int    htmlstatus = Web.DownloadBinaryInform(Xml.GetXmlBinaryInform(model, region, pda, csc, phone, data, BinaryNature), out xmlresponse);

            if (htmlstatus != 200 || Utility.GetXMLStatusCode(xmlresponse) != 200)
            {
                Logger.WriteLog("Error: Could not send BinaryInform. Status code " + (object)htmlstatus + "/" + (object)Utility.GetXMLStatusCode(xmlresponse), false);
                Utility.CheckHTMLXMLStatus(htmlstatus, Utility.GetXMLStatusCode(xmlresponse));
                return(firmware);
            }
            firmware.Version      = Xml.GetXMLValue(xmlresponse, "FUSBody/Results/LATEST_FW_VERSION/Data", (string)null, (string)null);
            firmware.Model        = Xml.GetXMLValue(xmlresponse, "FUSBody/Put/DEVICE_MODEL_NAME/Data", (string)null, (string)null);
            firmware.DisplayName  = Xml.GetXMLValue(xmlresponse, "FUSBody/Put/DEVICE_MODEL_DISPLAYNAME/Data", (string)null, (string)null);
            firmware.OS           = Xml.GetXMLValue(xmlresponse, "FUSBody/Put/LATEST_OS_VERSION/Data", (string)null, (string)null);
            firmware.LastModified = Xml.GetXMLValue(xmlresponse, "FUSBody/Put/LAST_MODIFIED/Data", (string)null, (string)null);
            firmware.Filename     = Xml.GetXMLValue(xmlresponse, "FUSBody/Put/BINARY_NAME/Data", (string)null, (string)null);
            firmware.Size         = Xml.GetXMLValue(xmlresponse, "FUSBody/Put/BINARY_BYTE_SIZE/Data", (string)null, (string)null);
            string xmlValue = Xml.GetXMLValue(xmlresponse, "FUSBody/Put/BINARY_CRC/Data", (string)null, (string)null);

            if (!string.IsNullOrEmpty(xmlValue))
            {
                firmware.CRC = ((IEnumerable <byte>)BitConverter.GetBytes(Convert.ToUInt32(xmlValue))).Reverse <byte>().ToArray <byte>();
            }
            firmware.Model_Type   = Xml.GetXMLValue(xmlresponse, "FUSBody/Put/DEVICE_MODEL_TYPE/Data", (string)null, (string)null);
            firmware.Path         = Xml.GetXMLValue(xmlresponse, "FUSBody/Put/MODEL_PATH/Data", (string)null, (string)null);
            firmware.Region       = Xml.GetXMLValue(xmlresponse, "FUSBody/Put/DEVICE_LOCAL_CODE/Data", (string)null, (string)null);
            firmware.BinaryNature = int.Parse(Xml.GetXMLValue(xmlresponse, "FUSBody/Put/BINARY_NATURE/Data", (string)null, (string)null));
            if (Xml.GetXMLValue(xmlresponse, "FUSBody/Put/LOGIC_OPTION_FACTORY/Data", (string)null, (string)null) == "1")
            {
                firmware.LogicValueFactory = Xml.GetXMLValue(xmlresponse, "FUSBody/Put/LOGIC_VALUE_FACTORY/Data", (string)null, (string)null);
            }
            if (Xml.GetXMLValue(xmlresponse, "FUSBody/Put/LOGIC_OPTION_HOME/Data", (string)null, (string)null) == "1")
            {
                firmware.LogicValueHome = Xml.GetXMLValue(xmlresponse, "FUSBody/Put/LOGIC_VALUE_HOME/Data", (string)null, (string)null);
            }
            if (!AutoFetch)
            {
                if (pda + "/" + csc + "/" + phone + "/" + pda == firmware.Version)
                {
                    Logger.WriteLog("\nCurrent firmware is latest:", false);
                }
                else
                {
                    Logger.WriteLog("\nNewer firmware available:", false);
                }
            }
            Logger.WriteLog("Model: " + firmware.Model, false);
            Logger.WriteLog("Version: " + firmware.Version, false);
            Logger.WriteLog("OS: " + firmware.OS, false);
            Logger.WriteLog("Filename: " + firmware.Filename, false);
            Logger.WriteLog("Size: " + firmware.Size + " bytes", false);
            if (firmware.BinaryNature == 1 && !string.IsNullOrEmpty(firmware.LogicValueFactory))
            {
                Logger.WriteLog("LogicValue: " + firmware.LogicValueFactory, false);
            }
            else if (!string.IsNullOrEmpty(firmware.LogicValueHome))
            {
                Logger.WriteLog("LogicValue: " + firmware.LogicValueHome, false);
            }
            Logger.WriteLog("\n", false);
            return(firmware);
        }