Beispiel #1
0
        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);
        }
Beispiel #2
0
 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);
     }
 }
Beispiel #3
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);
        }