Exemple #1
0
        public Update(UpdateNode node)
        {
            this.request = node.getRequest();
            this.url = node.getUrl();
            this.version = node.getVersion();
            this.dir = node.getDir();
            this.success = false;

            this.changelog = new Changelog(version);
        }
        public Update(UpdateNode node)
        {
            this.request = node.getRequest();
            this.url     = node.getUrl();
            this.version = node.getVersion();
            this.dir     = node.getDir();
            this.success = false;

            this.changelog = new Changelog(version);
        }
Exemple #3
0
        private List <UpdateNode> getUpdateNodes()
        {
            List <UpdateNode> updateNodes = new List <UpdateNode>();

            if (isDead())
            {
                return(updateNodes);
            }

            try {
                var root = from item in serverXML.Descendants("Server")
                           select new {
                    updates = item.Descendants("Update")
                };

                foreach (var data in root)
                {
                    foreach (var update in data.updates)
                    {
                        String versionStr = update.Attribute("version").Value.Trim();
                        try {
                            XAttribute dir     = update.Attribute("dir");
                            double     version = Convert.ToDouble(versionStr);
                            if (version > lastVersion)
                            {
                                UpdateNode updateNode = new UpdateNode(this, update.Value.Trim(), version, dir != null ? dir.Value : "");
                                updateNodes.Add(updateNode);
                                Logger.log(Logger.TYPE.DEBUG, "Found a new update: " + versionStr + ", url: " + updateNode.getFullPath());
                            }
                        }
                        catch (FormatException e) {
                            Logger.log(Logger.TYPE.ERROR, "Problem converting 'version' for update "
                                       + versionStr + e.Message);
                        }
                    }
                }
            }
            catch (Exception ex) {
                Logger.log(Logger.TYPE.ERROR, "Problem while getting update nodes "
                           + ex.Message + ex.StackTrace);
            }
            return(updateNodes);
        }
Exemple #4
0
        private List<UpdateNode> getUpdateNodes()
        {
            List<UpdateNode> updateNodes = new List<UpdateNode>();
            if (isDead()) {
                return updateNodes;
            }

            try {
                var root = from item in serverXML.Descendants("Server")
                    select new {
                        updates = item.Descendants("Update")
                    };

                foreach (var data in root) {
                    foreach (var update in data.updates) {
                        String versionStr = update.Attribute("version").Value.Trim();
                        try {
                            XAttribute dir = update.Attribute("dir");
                            double version = Convert.ToDouble(versionStr);
                            if (version > lastVersion) {
                                UpdateNode updateNode = new UpdateNode(this, update.Value.Trim(), version, dir != null ? dir.Value : "");
                                updateNodes.Add(updateNode);
                                Logger.log(Logger.TYPE.DEBUG, "Found a new update: " + versionStr + ", url: " + updateNode.getFullPath());
                            }
                        }
                        catch (FormatException e) {
                            Logger.log(Logger.TYPE.ERROR, "Problem converting 'version' for update "
                                + versionStr + e.Message);
                        }
                    }
                }
            }
            catch (Exception ex) {
                Logger.log(Logger.TYPE.ERROR, "Problem while getting update nodes "
                    + ex.Message + ex.StackTrace);
            }
            return updateNodes;
        }
Exemple #5
0
        private Update compileUpdate(UpdateNode node, XDocument xml)
        {
            Update update = new Update(node);
            if (isDead()) {
                return update;
            }

            try {
                var root = from item in xml.Descendants("Update")
                    select new {
                        changelog = item.Descendants("Changelog"),
                        files = item.Descendants("File"),
                        archives = item.Descendants("Archive"),
                        name = item.Attribute("name"),
                        baseType = item.Attribute("base")
                    };

                foreach (var data in root) {

                    // Set Attributes
                    update.setName(data.name.Value);
                    if (data.baseType != null) {
                        update.setBaseType(data.baseType.Value);
                    }

                    // Add the changelog data
                    foreach (var clog in data.changelog) {
                        Changelog changelog = new Changelog(update.getVersion());
                        foreach (var log in clog.Descendants("Log")) {
                            changelog.addLog(new Changelog.Log(log.Value.Trim()));
                        }
                        update.setChangelog(changelog);
                        break;
                    }

                    // Add the file data
                    foreach (var f in data.files) {
                        String name = Xml.getAttributeValue(f.Attribute("name"));
                        String destination = Xml.getAttributeValue(f.Attribute("destination"));
                        String mime = Xml.getAttributeValue(f.Attribute("mime"), "none");

                        update.addFile(new GhostFile(name, destination, mime,
                            new Uri(url + "/" + node.getDir() + "/" + name)));
                    }

                    // Add the archive data
                    foreach (var f in data.archives) {
                        String name = Xml.getAttributeValue(f.Attribute("name"));
                        String extractTo = Xml.getAttributeValue(f.Attribute("extractTo"));
                        String mime = Xml.getAttributeValue(f.Attribute("mime"), "none");

                        Boolean cleanDirs = false;
                        if (f.Attribute("cleanDirs") != null) {
                            cleanDirs = Convert.ToBoolean(f.Attribute("cleanDirs").Value.Trim());
                        }

                        update.addFile(new Archive(name, extractTo, mime,
                            new Uri(url + "/" + node.getDir() + "/" + name), cleanDirs));
                    }
                }
            }
            catch (Exception ex) {
                Logger.log(Logger.TYPE.ERROR, "Problem while compiling updates "
                    + ex.Message + ex.StackTrace);
            }

            return update;
        }
Exemple #6
0
        private Update compileUpdate(UpdateNode node, XDocument xml)
        {
            Update update = new Update(node);

            if (isDead())
            {
                return(update);
            }

            try {
                var root = from item in xml.Descendants("Update")
                           select new {
                    changelog = item.Descendants("Changelog"),
                    files     = item.Descendants("File"),
                    archives  = item.Descendants("Archive"),
                    name      = item.Attribute("name"),
                    baseType  = item.Attribute("base")
                };

                foreach (var data in root)
                {
                    // Set Attributes
                    update.setName(data.name.Value);
                    if (data.baseType != null)
                    {
                        update.setBaseType(data.baseType.Value);
                    }

                    // Add the changelog data
                    foreach (var clog in data.changelog)
                    {
                        Changelog changelog = new Changelog(update.getVersion());
                        foreach (var log in clog.Descendants("Log"))
                        {
                            changelog.addLog(new Changelog.Log(log.Value.Trim()));
                        }
                        update.setChangelog(changelog);
                        break;
                    }

                    // Add the file data
                    foreach (var f in data.files)
                    {
                        String name        = Xml.getAttributeValue(f.Attribute("name"));
                        String destination = Xml.getAttributeValue(f.Attribute("destination"));
                        String mime        = Xml.getAttributeValue(f.Attribute("mime"), "none");

                        update.addFile(new GhostFile(name, destination, mime,
                                                     new Uri(url + "/" + node.getDir() + "/" + name)));
                    }

                    // Add the archive data
                    foreach (var f in data.archives)
                    {
                        String name      = Xml.getAttributeValue(f.Attribute("name"));
                        String extractTo = Xml.getAttributeValue(f.Attribute("extractTo"));
                        String mime      = Xml.getAttributeValue(f.Attribute("mime"), "none");

                        Boolean cleanDirs = false;
                        if (f.Attribute("cleanDirs") != null)
                        {
                            cleanDirs = Convert.ToBoolean(f.Attribute("cleanDirs").Value.Trim());
                        }

                        update.addFile(new Archive(name, extractTo, mime,
                                                   new Uri(url + "/" + node.getDir() + "/" + name), cleanDirs));
                    }
                }
            }
            catch (Exception ex) {
                Logger.log(Logger.TYPE.ERROR, "Problem while compiling updates "
                           + ex.Message + ex.StackTrace);
            }

            return(update);
        }