public static string FOTAInfoFetch(string model, string region, bool latest = true) { string str3; try { using (WebClient client = new WebClient()) { string xml = client.DownloadString("http://fota-cloud-dn.ospserver.net/firmware/" + region + "/" + model + "/version.xml"); string str2 = null; if (latest) { str2 = Xml.GetXMLValue(xml, "firmware/version/latest", null, null).ToUpper(); } else { str2 = Xml.GetXMLValue(xml, "firmware/version/upgrade/value", null, null).ToUpper(); } str3 = str2; } } catch (Exception) { str3 = string.Empty; } return(str3); }
public static int GetXmlStatusCode(string xml) { int num; if (string.IsNullOrEmpty(xml)) { return(0); } if (int.TryParse(Xml.GetXMLValue(xml, "FUSBody/Results/Status", null, null), out num)) { return(num); } return(666); }
public static int GetXMLStatusCode(string xml) { if (string.IsNullOrEmpty(xml)) { return(0); } int result; if (int.TryParse(Xml.GetXMLValue(xml, "FUSBody/Results/Status", (string)null, (string)null), out result)) { return(result); } return(666); }
public static string FOTAInfoFetch(string model, string region, bool latest = true) { try { using (WebClient webClient = new WebClient()) { string xml = webClient.DownloadString("http://fota-cloud-dn.ospserver.net/firmware/" + region + "/" + model + "/version.xml"); return(!latest?Xml.GetXMLValue(xml, "firmware/version/upgrade/value", (string)null, (string)null).ToUpper() : Xml.GetXMLValue(xml, "firmware/version/latest", (string)null, (string)null).ToUpper()); } } catch (Exception ex) { return(string.Empty); } }
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); }
public static Firmware UpdateCheck(string model, string region, string pda, string csc, string phone, string data, bool BinaryNature, bool AutoFetch = false) { string str; Firmware firmware = new Firmware(); Logger.WriteLine("Checking firmware for " + model + "/" + region + "/" + pda + "/" + csc + "/" + phone + "/" + data); int htmlstatus = Web.GenerateNonce(); if (htmlstatus != 200) { Logger.WriteLine("Error UpdateCheck(): Could not generate Nonce. Status code (" + htmlstatus + ")"); firmware.ConnectionError = true; return(firmware); } htmlstatus = Web.DownloadBinaryInform(Xml.GetXmlBinaryInform(model, region, pda, csc, phone, data, BinaryNature), out str); if ((htmlstatus != 200) || (Utility.GetXmlStatusCode(str) != 200)) { Logger.WriteLine("Error UpdateCheck(): Could not send BinaryInform. Status code (" + htmlstatus + "/" + Utility.GetXmlStatusCode(str) + ")"); Utility.CheckHtmlXmlStatus(htmlstatus, Utility.GetXmlStatusCode(str)); return(firmware); } firmware.Version = Xml.GetXMLValue(str, "FUSBody/Results/LATEST_FW_VERSION/Data", null, null); firmware.Model = Xml.GetXMLValue(str, "FUSBody/Put/DEVICE_MODEL_NAME/Data", null, null); firmware.DisplayName = Xml.GetXMLValue(str, "FUSBody/Put/DEVICE_MODEL_DISPLAYNAME/Data", null, null); firmware.OS = Xml.GetXMLValue(str, "FUSBody/Put/LATEST_OS_VERSION/Data", null, null); firmware.LastModified = Xml.GetXMLValue(str, "FUSBody/Put/LAST_MODIFIED/Data", null, null); firmware.Filename = Xml.GetXMLValue(str, "FUSBody/Put/BINARY_NAME/Data", null, null); firmware.Size = Xml.GetXMLValue(str, "FUSBody/Put/BINARY_BYTE_SIZE/Data", null, null); string str3 = Xml.GetXMLValue(str, "FUSBody/Put/BINARY_CRC/Data", null, null); if (!string.IsNullOrEmpty(str3)) { firmware.CRC = BitConverter.GetBytes(Convert.ToUInt32(str3)).Reverse <byte>().ToArray <byte>(); } firmware.Model_Type = Xml.GetXMLValue(str, "FUSBody/Put/DEVICE_MODEL_TYPE/Data", null, null); firmware.Path = Xml.GetXMLValue(str, "FUSBody/Put/MODEL_PATH/Data", null, null); firmware.Region = Xml.GetXMLValue(str, "FUSBody/Put/DEVICE_LOCAL_CODE/Data", null, null); firmware.BinaryNature = int.Parse(Xml.GetXMLValue(str, "FUSBody/Put/BINARY_NATURE/Data", null, null)); if (Xml.GetXMLValue(str, "FUSBody/Put/LOGIC_OPTION_FACTORY/Data", null, null) == "1") { firmware.LogicValueFactory = Xml.GetXMLValue(str, "FUSBody/Put/LOGIC_VALUE_FACTORY/Data", null, null); } if (Xml.GetXMLValue(str, "FUSBody/Put/LOGIC_OPTION_HOME/Data", null, null) == "1") { firmware.LogicValueHome = Xml.GetXMLValue(str, "FUSBody/Put/LOGIC_VALUE_HOME/Data", null, null); } if (!AutoFetch) { if ((pda + "/" + csc + "/" + phone + "/" + pda) == firmware.Version) { Logger.WriteLine("\nCurrent firmware is latest:"); } else { Logger.WriteLine("\nNewer firmware available:"); } } Logger.WriteLine("Model: " + firmware.Model); Logger.WriteLine("Version: " + firmware.Version); Logger.WriteLine("OS: " + firmware.OS); Logger.WriteLine("Filename: " + firmware.Filename); Logger.WriteLine("Size: " + firmware.Size + " bytes"); if ((firmware.BinaryNature == 1) && !string.IsNullOrEmpty(firmware.LogicValueFactory)) { Logger.WriteLine("LogicValue: " + firmware.LogicValueFactory); } else if (!string.IsNullOrEmpty(firmware.LogicValueHome)) { Logger.WriteLine("LogicValue: " + firmware.LogicValueHome); } return(firmware); }