Ejemplo n.º 1
0
        private static DescriptionFileData GetDescriptionFileData(string _AddonName, string _AddonPackageFile)
        {
            string addonDescription = "";

            using (var fileStream = new System.IO.FileStream(_AddonPackageFile, System.IO.FileMode.Open, System.IO.FileAccess.Read))
            {
                using (var zipFile = new ZipFile(fileStream))
                {
                    var zipEntry = zipFile.GetEntry(_AddonName + "/VF_WowLauncher_AddonDescription.txt");
                    if (zipEntry == null)
                    {
                        zipEntry = zipFile.GetEntry(_AddonName + "\\VF_WowLauncher_AddonDescription.txt");
                        if (zipEntry != null)
                        {
                            Logger.ConsoleWriteLine("This actually does happen!");
                        }
                    }
                    if (zipEntry != null)
                    {
                        using (var inputStream = zipFile.GetInputStream(zipEntry))
                        {
                            using (System.IO.TextReader textReader = new System.IO.StreamReader(inputStream, Encoding.UTF8))
                            {
                                addonDescription = textReader.ReadToEnd();
                            }
                        }
                    }
                }
            }
            if (addonDescription == "")
            {
                return(null);
            }

            DescriptionFileData descFileData = new DescriptionFileData();

            string[] DescEntries = addonDescription.SplitVF("\r\n#");
            foreach (var descEntry in DescEntries)
            {
                var descEntryType = descEntry.Substring(0, descEntry.IndexOf('=') + 1).ToLower();
                if (descEntryType.StartsWith("description=")) //Description=
                {
                    descFileData.UpdateDescription = descEntry.Substring("Description=".Length);
                }
                else if (descEntryType.StartsWith("version=")) //Version=
                {
                    descFileData.UpdateVersion = descEntry.Substring("Version=".Length);
                }
                else if (descEntryType.StartsWith("clearwtfrequired=")) //ClearWTFRequired=
                {
                    descFileData.ClearWTFRequiredStr = descEntry.Substring("ClearWTFRequired=".Length);
                }
                else if (descEntryType.ToLower().StartsWith("updatesubmitter=")) //UpdateSubmitter=
                {
                    descFileData.UpdateSubmitter = descEntry.Substring("UpdateSubmitter=".Length);
                }
                else if (descEntryType.ToLower().StartsWith("updateimportance=")) //UpdateImportance=
                {
                    descFileData.UpdateImportanceStr = descEntry.Substring("UpdateImportance=".Length);
                }
            }
            if (descFileData.UpdateVersion == "" || descFileData.UpdateDescription == "")
            {
                return(null);
            }
            descFileData.AddonName = _AddonName;
            return(descFileData);
        }
Ejemplo n.º 2
0
        public static WLN_ResponsePacket_AddonUpdateInfo GetAddonUpdate(string _UserID, WLN_RequestPacket_AddonUpdateInfo _Request)
        {
            string addonName = _Request.AddonName;
            string latestAddonPackageFilename = GetLatestAddonPackageFilename(addonName);

            if (latestAddonPackageFilename == "")
            {
                return(null);
            }

            if (IsAddonBeta(addonName) && _Request.CurrentVersion == "0.0")
            {
                if (IsBetaParticipant(addonName, _UserID) == false)
                {
                    return(null);
                }
            }
            try
            {
                DescriptionFileData addonDescription = GetDescriptionFileData(addonName, latestAddonPackageFilename);
                if (addonDescription == null)
                {
                    return(null);
                }

                WLN_ResponsePacket_AddonUpdateInfo addonUpdateInfo = new WLN_ResponsePacket_AddonUpdateInfo();
                addonUpdateInfo.AddonName      = addonName;
                addonUpdateInfo.CurrentVersion = _Request.CurrentVersion;

                addonUpdateInfo.UpdateVersion     = "";
                addonUpdateInfo.UpdateDescription = "";
                addonUpdateInfo.ClearAccountSavedVariablesRequired   = false;
                addonUpdateInfo.ClearCharacterSavedVariablesRequired = false;
                addonUpdateInfo.UpdateSubmitter  = "Unknown";
                addonUpdateInfo.UpdateImportance = ServerComm.UpdateImportance.Minor;


                addonUpdateInfo.UpdateVersion     = addonDescription.UpdateVersion;
                addonUpdateInfo.UpdateDescription = addonDescription.UpdateDescription;
                addonUpdateInfo.UpdateSubmitter   = addonDescription.UpdateSubmitter;
                if (addonUpdateInfo.UpdateSubmitter == "")
                {
                    addonUpdateInfo.UpdateSubmitter = "Unknown";
                }
                addonUpdateInfo.ClearAccountSavedVariablesRequired   = addonDescription.GetClearAccountSavedVariablesRequired(addonUpdateInfo.CurrentVersion);
                addonUpdateInfo.ClearCharacterSavedVariablesRequired = addonDescription.GetClearCharacterSavedVariablesRequired(addonUpdateInfo.CurrentVersion);
                addonUpdateInfo.UpdateImportance = addonDescription.GetUpdateImportance(addonUpdateInfo.CurrentVersion);
                if (_Request.CurrentVersion == "0.0")
                {
                    if (addonName == "VF_RealmPlayers")
                    {
                        addonUpdateInfo.UpdateDescription = "Latest addon version for gathering data and contribute to the armory at realmplayers.com";
                        addonUpdateInfo.UpdateSubmitter   = "Dilatazu";
                    }
                    else if (addonName == "VF_RaidDamage" || addonName == "VF_RaidStats")
                    {
                        addonUpdateInfo.UpdateDescription = "Latest addon version for automatically logging data in raids. Logged raids will automatically be uploaded to RaidStats";
                        addonUpdateInfo.UpdateSubmitter   = "Dilatazu";
                    }
                    else if (addonName == "VF_BGStats")
                    {
                        addonUpdateInfo.UpdateDescription = "Latest addon version for automatically logging data in battlegrounds. Logged bgs will automatically be uploaded to BGStats";
                        addonUpdateInfo.UpdateSubmitter   = "Dilatazu";
                    }
                    else if (addonName == "VF_RealmPlayersTBC")
                    {
                        addonUpdateInfo.UpdateDescription = "Latest addon version for gathering data and contribute to the armory at realmplayers.com";
                        addonUpdateInfo.UpdateSubmitter   = "Dilatazu";
                    }
                    else if (addonName == "VF_RaidStatsTBC")
                    {
                        addonUpdateInfo.UpdateDescription = "Latest addon version for automatically logging data in raids. Logged raids will automatically be uploaded to RaidStats";
                        addonUpdateInfo.UpdateSubmitter   = "Dilatazu";
                    }
                    else if (addonName == "VF_BGStatsTBC")
                    {
                        addonUpdateInfo.UpdateDescription = "Latest addon version for automatically logging data in battlegrounds. Logged bgs will automatically be uploaded to BGStats";
                        addonUpdateInfo.UpdateSubmitter   = "Dilatazu";
                    }
                    addonUpdateInfo.UpdateImportance = ServerComm.UpdateImportance.Good;
                }
                if (addonUpdateInfo.UpdateVersion == "")
                {
                    Logger.ConsoleWriteLine("AddonPackage \"" + latestAddonPackageFilename + "\" has invalid UpdateVersion, AddonPackage is not valid!");
                    return(null); //Invalid UpdateVersion, AddonPackage is not valid!
                }
                if (wyVersionChecker.Compare(addonDescription.UpdateVersion, addonUpdateInfo.CurrentVersion) > 0)
                {
                    addonUpdateInfo.AddonPackageDownloadFTP = AddonUpdateDownloadFTPAddress + latestAddonPackageFilename.Substring(AddonUpdateFolder.Length);
                    return(addonUpdateInfo);
                }
                else
                {
                    return(null);
                }
            }
            catch (Exception ex)
            {
                Logger.LogException(ex);
            }
            return(null);
        }