示例#1
0
    private void ReadConfigsIndex()
    {
        XmlTextReader reader = new XmlTextReader(Program.ProgramSettings.ConfigsIndexURL);

        ConfigPack temp = new ConfigPack();

        while (reader.Read())
        {
            if (temp.FriendlyName != null && temp.URL != null && temp.upd != 0)
            {
                temp = new ConfigPack();
            }
            switch (reader.NodeType)
            {
            case XmlNodeType.Element:
                if (reader.Name == "cpack-index-sheet")
                {
                    continue;
                }
                //Console.Write("<{0}", reader.Name);
                while (reader.MoveToNextAttribute())
                {
                    //Console.Write(" {0}='{1}'", reader.Name, reader.Value);
                    switch (reader.Name)
                    {
                    case "name":
                        temp.FriendlyName = reader.Value;
                        break;

                    case "upd":
                        temp.upd = int.Parse(reader.Value);
                        break;
                    }
                }
                //Console.Write(">");
                break;

            case XmlNodeType.Text:
                //Console.WriteLine(reader.Value);
                temp.URL = reader.Value;
                if (temp.URL != null && temp.FriendlyName != null)
                {
                    ConfigList.Add(temp);
                }
                break;

            case XmlNodeType.EndElement:
                //Console.WriteLine("</{0}>", reader.Name);
                if (temp.URL != null && temp.FriendlyName != null)
                {
                    ConfigList.Add(temp);
                }
                break;
            }
        }
    }
示例#2
0
    private static ConfigPackInformation ReadPackInformation(ConfigPack selected)
    {
        WebClient   wc          = new WebClient();
        string      fullXmlText = wc.DownloadString(Program.ProgramSettings.ConfigsRepoURL + selected.URL + "pge_cpack.xml");
        XmlDocument doc         = new XmlDocument();

        doc.LoadXml(fullXmlText);

        ConfigPackInformation cpi = new ConfigPackInformation();


        foreach (XmlNode node in doc.DocumentElement.ChildNodes)
        {
            if (cpi.PackName == null)
            {
                cpi.PackName = node.ParentNode.Attributes["name"].Value;
            }
            switch (node.Name)
            {
            case ("head"):
                cpi = IterateThroughHead(node, cpi);
                break;

            case ("files"):
                if (node.HasChildNodes)
                {
                    foreach (XmlNode fileNode in node.ChildNodes)
                    {
                        if (fileNode.Name == "file")
                        {
                            FilesStruct temp = new FilesStruct();
                            //temp.Platform = (fileNode.Attributes["platform"].Value);
                            temp.Folder = (fileNode.Attributes["folder"].Value == null) ? "" : fileNode.Attributes["folder"].Value;
                            temp.URL    = fileNode.InnerText;

                            if (temp.URL != null && temp.Folder != null)
                            {
                                cpi.FilesParts.Add(temp);
                            }
                        }
                    }
                }
                break;
            }
        }
        if (cpi.SplashURL != null && cpi.SplashURL != "")
        {
            cpi.SplashURL = Program.ProgramSettings.ConfigsRepoURL + selected.URL + cpi.SplashURL;
        }
        if (cpi.IconURL != null && cpi.IconURL != "")
        {
            cpi.IconURL = Program.ProgramSettings.ConfigsRepoURL + selected.URL + cpi.IconURL;
        }
        return(cpi);
    }
示例#3
0
 private long GetPackVersion(ConfigPack cfg)
 {
     foreach (var installed in Program.ProgramSettings.InstalledConfigs)
     {
         if (cfg.URL.Trim('/') == installed.Key)
         {
             return(installed.Value);
         }
     }
     return(0L);
 }
示例#4
0
    private void InitializeConfigTreeView()
    {
        List <ConfigPack> PacksThatNeedUpdating = new List <ConfigPack>();

        Gtk.ListStore configPackModel = new ListStore(typeof(string), typeof(string), typeof(string));
        configListTreeview.AppendColumn("Pack Name", new CellRendererText(), "text", 0);
        configListTreeview.AppendColumn("Upload Date", new CellRendererText(), "text", 1);
        configListTreeview.AppendColumn("Installed", new CellRendererText(), "text", 2);
        foreach (var cfg in ConfigList)
        {
            bool   exists         = false;
            string pathToCheck    = Program.ProgramSettings.PGEDirectory + System.IO.Path.DirectorySeparatorChar + "configs" + System.IO.Path.DirectorySeparatorChar + cfg.URL.Trim('/');
            long   cfgPackVersion = 0;
            if (cfg.URL.ToLower() == "smbx13/")
            {
                if (Directory.Exists(Program.ProgramSettings.PGEDirectory + System.IO.Path.DirectorySeparatorChar + "configs" + System.IO.Path.DirectorySeparatorChar + "SMBX"))
                {
                    exists = true;
                }
                cfgPackVersion = GetPackVersion(cfg);
            }
            else if (cfg.URL == "SMBX_Redrawn/")
            {
                if (Directory.Exists(Program.ProgramSettings.PGEDirectory + System.IO.Path.DirectorySeparatorChar + "configs" + System.IO.Path.DirectorySeparatorChar + "SMBX_Redrawn"))
                {
                    exists = true;
                }
                cfgPackVersion = GetPackVersion(cfg);
            }
            else if (cfg.URL == "A2MBXT/")
            {
                if (Directory.Exists(Program.ProgramSettings.PGEDirectory + System.IO.Path.DirectorySeparatorChar + "configs" + System.IO.Path.DirectorySeparatorChar + "Raocow (A2MBXT)"))
                {
                    exists = true;
                }
                cfgPackVersion = GetPackVersion(cfg);
            }
            else if (Directory.Exists(pathToCheck))
            {
                exists         = true;
                cfgPackVersion = GetPackVersion(cfg);
            }
            if (exists)
            {
                if (cfg.upd > cfgPackVersion)
                {
                    PacksThatNeedUpdating.Add(cfg);
                }
            }
            if (exists)
            {
                configPackModel.AppendValues(
                    cfg.FriendlyName,
                    ConfigPack.UnixTimeStampToDateTime((double)cfg.upd).ToString(), exists + " (" + ConfigPack.UnixTimeStampToDateTime((double)cfgPackVersion) + ")");
            }
            else
            {
                configPackModel.AppendValues(
                    cfg.FriendlyName,
                    ConfigPack.UnixTimeStampToDateTime((double)cfg.upd).ToString(), exists.ToString());
            }
        }
        configListTreeview.Model = configPackModel;
        if (PacksThatNeedUpdating.Count > 0)
        {
            NotifyUserOfUpdates(PacksThatNeedUpdating);
        }
    }