Esempio n. 1
0
        public bool IsAddonUptoDate(AddonMetaData addon, MelderInfo melderInfo)
        {
            // There are many ways to make a bad version string :<
            addon.Version      = Statics.CleanVersionString(addon.Version);
            melderInfo.Version = Statics.CleanVersionString(melderInfo.Version);


            try
            {
                Version current = new Version(addon.Version);
                Version newVer  = new Version(melderInfo.Version);

                return(current.CompareTo(newVer) == 0 || current.CompareTo(newVer) == 1);
            }
            catch (Exception)
            {
                return(false);
            }
        }
Esempio n. 2
0
 public override MelderInfo GetMelderInfo(string url)
 {
     if (Init(url))
     {
         DownloadAddon();
         AddonMetaData meta = AddonManager.ParseZipForIni(info.packedFile);
         if (meta != null)
         {
             MelderInfo mInfo = new MelderInfo();
             mInfo.IsNotSuported = !IsSupported();
             mInfo.Version       = meta.Version;
             mInfo.Patch         = meta.Patch;
             mInfo.ProviderType  = meta.ProviderType;
             mInfo.Dlurl         = url;
             return(mInfo);
         }
     }
     return(null);
 }
Esempio n. 3
0
        public virtual MelderInfo GetMelderInfo(string url)
        {
            try
            {
                MelderInfo Info = new MelderInfo();
                Info.IsNotSuported = false;

                WebClient client = new WebClient();
                client.Headers["User-Agent"] = Properties.Settings.Default.Useragent;

                string PageData = client.DownloadString(url);
                if (PageData != null)
                {
                    // Check if not suported
                    string StartTag = "<span class=\"prefix prefixGray\">";
                    int    start    = PageData.IndexOf(StartTag);
                    if (start != -1 && start < PageData.Length)
                    {
                        string tag = PageData.Substring(start + StartTag.Length);
                        int    end = tag.IndexOf("</span>");
                        tag = tag.Substring(0, end);
                        tag = tag.Replace("\n", "").Replace("\r", "").Trim();

                        Info.IsNotSuported = (tag.Contains("Not Supported"));
                    }

                    // Melder info
                    int    trimStart  = PageData.IndexOf("[melder_info]") + "[melder_info]".Length;
                    int    trimEnd    = PageData.IndexOf("[/melder_info]");
                    string MelderData = PageData.Substring(trimStart, trimEnd - trimStart);
                    if (MelderData != null)
                    {
                        string[] values = MelderData.Split(';');
                        foreach (string str in values)
                        {
                            if (str.Length > 1)
                            {
                                string[] args  = str.Split('=');
                                string   key   = args[0].ToLower().Trim();
                                string   value = args[1].Trim();

                                switch (key)
                                {
                                case "version":
                                    Info.Version = value;
                                    break;

                                case "patch":
                                    Info.Patch = value;
                                    break;

                                case "dlurl":
                                    Info.Dlurl = value;
                                    break;

                                case "providertype":
                                    Info.ProviderType = (AddonProviderType)Enum.Parse(typeof(AddonProviderType), value, true);
                                    break;
                                }
                            }
                        }

                        client.Dispose();
                        return(Info);
                    }
                }

                client.Dispose();
                return(null);
            }
            catch (Exception e)
            {
                Debug.WriteLine(e.Message);
            }
            return(null);
        }