Пример #1
0
 public Project(GUIIface gui, String rootDir)
 {
     linkQueue_ = new LinkQueue(gui.GetDispatcher());
     badLinkQueue_ = new LinkQueue(gui.GetDispatcher());
     startingUris_ = new ObservableCollection<Uri>();
     RootDirectory = rootDir;
 }
Пример #2
0
        public Worker(GUIIface gui, Project p)
        {
            this.p = p;
            Parser = new LuaHTMLParser(gui, p);
            Writer = new FileWriter(p);

            Progress.PropertyChanged += new PropertyChangedEventHandler(Progress_PropertyChanged);
        }
Пример #3
0
 public static Project Load(GUIIface gui, String proj)
 {
     FileStream fs = new FileStream(proj, FileMode.Open, FileAccess.Read, FileShare.Read);
     BinaryFormatter formatter = new BinaryFormatter();
     Project p = (Project)formatter.Deserialize(fs);
     p.ResetVolatileData(gui);
     fs.Close();
     return p;
 }
Пример #4
0
 public Context(Dispatcher d, GUIIface gui)
 {
     this.gui = gui;
     //NewProject(Environment.GetFolderPath(Environment.SpecialFolder.MyPictures));
 }
Пример #5
0
        public LuaHTMLParser(GUIIface gui, Project p)
        {
            this.p = p;
            this.gui = gui;
            /*            string pkgpath = (string)lua["package.path"];
            if (pkgpath == null) pkgpath = "";
            pkgpath += ";" + System.Environment.CurrentDirectory + System.IO.Path.DirectorySeparatorChar + "lualibs" + System.IO.Path.DirectorySeparatorChar + "?.lua";
            lua["package.path"] = pkgpath;
            */
            lua["project"] = new ProjectInterfaceToLua(p);
            lua["queue"] = new QueueInterfaceToLua(p, this);
            lua["util"] = new UtilInterfaceToLua();
            lua.RegisterFunction("log", this, this.GetType().GetMethod("log"));
            lua.RegisterFunction("io.canwrite", this, this.GetType().GetMethod("CanWrite"));
            lua.RegisterFunction("io.ensurefolder", this, this.GetType().GetMethod("EnsureFolder"));
            lua.RegisterFunction("io.movefile", this, this.GetType().GetMethod("MoveFile"));
            lua.DoString(@"
            io.popen = function(prog, mode)
            error('Opening processes is disabled.')
            end
            do
            local realioopen = io.open
            local realioclose = io.close
            local ensurefolder = io.ensurefolder
            local movefile = io.movefile
            io.ensurefolder = nil
            local openfilenames = {}
            io.openfordl = function(filen, mode)
            filen = filen:gsub('/','\\')
            if filen:match('^\\') or filen:match('%.%.\\') or filen:match('^%w:') then
            error('Only relative paths that do not go up (..) are allowed')
            end

            filen = project.DownloadFolder .. '\\' .. filen

            ensurefolder(filen)

            if not io.canwrite(filen) then
            return nil, 'Cannot open file due to user settings.'
            end

            local tmpfilen = filen .. '.dlprog_part'

            local f,err = realioopen(tmpfilen,mode)
            if f then
            openfilenames[f] = filen
            end

            return f,err
            end
            io.open = function(filen, mode)
            filen = filen:gsub('/','\\')
            if filen:match('^\\') or filen:match('%.%.\\') or filen:match('^%w:') then
            error('Only relative paths that do not go up (..) are allowed')
            end

            filen = project.DownloadFolder .. '\\' .. filen

            ensurefolder(filen)

            return realioopen(filen,mode)
            end
            io.close = function(file)
            local ret = realioclose(file)
            local filen = openfilenames[file]

            if filen then
            movefile(filen .. '.dlprog_part',filen)
            openfilenames[file] = nil
            end

            return ret
            end
            end
            ");
        }
Пример #6
0
 public Workers(Project p, GUIIface gui)
 {
     this.p = p;
     this.gui = gui;
 }
Пример #7
0
 private void ResetVolatileData(GUIIface gui)
 {
     linkQueue_.SetDispatcher(gui.GetDispatcher());
     badLinkQueue_.SetDispatcher(gui.GetDispatcher());
 }