Beispiel #1
0
 public override (Uri url, HttpContent request) SetFilePriority(string hash, IEnumerable <int> fileIds, TorrentContentPriority priority)
 {
     return(BuildForm(Url.SetFilePriority(),
                      ("hash", hash),
                      ("id", string.Join("|", fileIds)),
                      ("priority", priority.ToString("D"))));
 }
Beispiel #2
0
 public override (Uri url, HttpContent request) StartSearch(string pattern, IEnumerable <string> plugins, string category)
 {
     return(BuildForm(Url.StartSearch(),
                      ("pattern", pattern),
                      ("plugins", string.Join("|", plugins)),
                      ("category", category)));
 }
Beispiel #3
0
 public override (Uri url, HttpContent request) SetShareLimits(IEnumerable <string> hashes, double ratio, TimeSpan seedingTime)
 {
     return(BuildForm(Url.SetShareLimits(),
                      ("hashes", JoinHashes(hashes)),
                      ("ratioLimit", ratio.ToString("R", CultureInfo.InvariantCulture)),
                      ("seedingTimeLimit", seedingTime.TotalSeconds.ToString("F0"))));
 }
Beispiel #4
0
 public override (Uri url, HttpContent request) RenameFolder(string hash, string oldPath, string newPath)
 {
     return(BuildForm(Url.RenameFolder(),
                      ("hash", hash),
                      ("oldPath", oldPath),
                      ("newPath", newPath)));
 }
Beispiel #5
0
 public override (Uri url, HttpContent request) RenameFile(string hash, int fileId, string newName)
 {
     return(BuildForm(Url.RenameFile(),
                      ("hash", hash),
                      ("id", fileId.ToString()),
                      ("name", newName)));
 }
Beispiel #6
0
 public override (Uri url, HttpContent request) EditTracker(string hash, Uri trackerUrl, Uri newTrackerUrl)
 {
     return(BuildForm(Url.EditTracker(),
                      ("hash", hash),
                      ("origUrl", trackerUrl.AbsoluteUri),
                      ("newUrl", newTrackerUrl.AbsoluteUri)));
 }
Beispiel #7
0
        public byte[] PackFiles(BuildForm bf, double remainingProgress)
        {
            byte[] ret = new byte[0];
            byte[] tmp;
            double baseProgress = bf.CurrentProgress();

            int iFile = 0;

            foreach (InstallerFile file in _objConfig.GetFiles())
            {
                if (!System.IO.File.Exists(file.LocalPath))
                {
                    Globals.Throw("The file " + file.LocalPath + " does not seem to exist, or there is a lock preventing Spark from reading it.  Skip Failures is not set to true. Spark will now exit.");
                }

                bf.DetailMessage("Packing: " + file.LocalPath);

                Globals.Logger.LogInfo("Packing " + file.LocalPath);
                tmp = System.IO.File.ReadAllBytes(file.LocalPath);
                ret = BufferUtils.Combine(ret, tmp);

                iFile++;

                double progress = baseProgress +
                                  ((double)iFile / (double)_objConfig.GetFiles().Count) * (1.0 - baseProgress - remainingProgress);

                bf.Progress(progress);
            }
            return(ret);
        }
        private void LoadConfiguration(BuildForm bf)
        {
            _objConfig = new InstallerConfig(SparkGlobals.BuildConfigPath);
            _objConfig.Load();
            _objConfig.BuildFileList();

            if (_objConfig.Options.GetOption(InstallOption.AppGuid) == null)
            {
                Globals.Throw("The install option 'AppGuid' is required. Please add this option to the input configuration file.");
            }

            //Attempt to parse GUID - if it is invalid an exception will throw.
            ProgramInfo.TryParseGuidToUninstallGuid(_objConfig.Options.GetOption(InstallOption.AppGuid).Value);

            if (_objConfig.Options.GetOption(InstallOption.DisplayName) == null)
            {
                Globals.Throw("The install option 'DisplayName' is required. Please add this option to the input configuration file.");
            }

            Globals.Logger.LogInfo("Excluded " + _objConfig.NumExcludedFiles + " files.");
            Globals.Logger.LogInfo("Excluded " + _objConfig.NumExcludedDirectories + " directories.");
            Globals.Logger.LogInfo("Packaging " + _objConfig.GetFiles().Count + " total files.");

            _objFileTable = new InstallerFileTable(_objConfig);
            bf.Progress(0.01);
        }
Beispiel #9
0
        static void Main(string[] args)
        {
            SparkGlobals.InitializeGlobals(args.ToList());
            string a   = System.IO.Directory.GetCurrentDirectory();
            string dir = System.IO.Path.GetDirectoryName(ExeUtils.GetCurrentExePath());

            System.IO.Directory.SetCurrentDirectory(dir);
            string b = System.IO.Directory.GetCurrentDirectory();

            //
            // Args to build
            //
            if (SparkGlobals.ProgramMode == SparkProgramMode.Build)
            {
                BuildForm bf = new BuildForm();
                try
                {
                    bf.Show();
                    InstallerBuilder ib = new InstallerBuilder();
                    ib.BuildInstaller(bf);
                    bf.Hide();
                }
                catch (Exception ex)
                {
                    System.Windows.Forms.MessageBox.Show(ex.ToString());
                }
            }
            else
            {
                Application.EnableVisualStyles();
                Application.SetCompatibleTextRenderingDefault(false);
                Application.Run(new MainForm());
            }
        }
        public override (Uri url, HttpContent request) Resume(IEnumerable <string> hashes)
        {
            var hashList = hashes.ToList();

            if (hashList.Count == 0)
            {
                throw new InvalidOperationException("Exactly one hash must be provided.");
            }

            if (hashList.Count > 1)
            {
                throw new ApiNotSupportedException("API 1.x does not support resuming several torrents at once.", ApiLevel.V2);
            }

            return(BuildForm(Url.Resume(),
                             ("hash", hashList[0])));
        }
 private void BuildConfig(BuildForm bf)
 {
     byte[] temp;
     bf.DetailMessage("Building Config.");
     temp   = _objConfig.Serialize();
     _final = BufferUtils.Combine(_final, temp);
     Globals.Logger.LogInfo("Config:" + temp.Length.ToString() + "B Total:" + _final.Length.ToString() + "B");
     bf.Progress(0.05);
 }
 private void BuildFileTable(BuildForm bf)
 {
     byte[] temp;
     bf.DetailMessage("Building File Table.");
     temp   = _objFileTable.Build(_final.Length);
     _final = BufferUtils.Combine(_final, temp);
     Globals.Logger.LogInfo("FileTable:" + temp.Length.ToString() + "B Total:" + _final.Length.ToString() + "B");
     bf.Progress(0.12);
 }
 private void BuildPostfixedBinary(BuildForm bf)
 {
     byte[] temp;
     bf.DetailMessage("Building Binary.");
     temp   = InstallerBinary.GetBytes();
     _final = BufferUtils.Combine(_final, temp);
     Globals.Logger.LogInfo("Binary:" + temp.Length.ToString() + "B Total:" + _final.Length.ToString() + "B");
     bf.Progress(0.03);
 }
        private void BuildFiles(BuildForm bf)
        {
            double remainingProgress = 0.02;

            byte[] temp;
            bf.DetailMessage("Building Files.");
            temp   = _objFileTable.PackFiles(bf, remainingProgress);
            _final = BufferUtils.Combine(_final, temp);
            Globals.Logger.LogInfo("Files:" + temp.Length.ToString() + "B Total:" + _final.Length.ToString() + "B");
            bf.Progress(1.0 - remainingProgress);
        }
        /*
         * See InstallerManager for file format.
         *
         */
        public void BuildInstaller(BuildForm bf)
        {
            if (String.IsNullOrEmpty(SparkGlobals.BuildConfigPath))
            {
                Globals.Throw("Build config path was not set.  Use the " + Spark.Installer.SparkFlags.ConfigPath + " flag to set this (" + Spark.Installer.SparkFlags.ConfigPath + ":\"path\\path\")");
            }
            if (String.IsNullOrEmpty(SparkGlobals.OutputFile))
            {
                Globals.Throw("Output file was not set.  Use the " + Spark.Installer.SparkFlags.OutputFile + " flag to set this (" + Spark.Installer.SparkFlags.OutputFile + ":\"file.exe\") ");
            }

            LoadConfiguration(bf);
            BuildPostfixedBinary(bf);
            BuildConfig(bf);
            BuildFileTable(bf);
            BuildFiles(bf);
            WriteFile(bf);
        }
Beispiel #16
0
 public override (Uri url, HttpContent request) DeleteTorrents(IEnumerable <string> hashes, bool withFiles)
 {
     return(BuildForm(Url.DeleteTorrents(withFiles),
                      ("hashes", JoinHashes(hashes)),
                      ("deleteFiles", withFiles.ToLowerString())));
 }
Beispiel #17
0
 public override (Uri url, HttpContent request) ResumeAll()
 {
     return(BuildForm(Url.ResumeAll(),
                      ("hashes", "all")));
 }
Beispiel #18
0
 public override (Uri url, HttpContent request) DeleteSearch(int id)
 {
     return(BuildForm(Url.DeleteSearch(),
                      ("id", id.ToString())));
 }
Beispiel #19
0
 public static IFormDialog <T> MakeForm <T>(BuildForm <T> buildForm) where T : class, new()
 {
     return(new FormDialog <T>(new T(), buildForm, options: FormOptions.PromptInStart));
 }
Beispiel #20
0
 private void BuildButton_Click(object sender, EventArgs e)
 {
     _buildForm = new BuildForm();
     _buildForm.Show(ParentForm);
 }
Beispiel #21
0
 public override (Uri url, HttpContent request) EditCategory(string category, string savePath)
 {
     return(BuildForm(Url.EditCategory(),
                      ("category", category),
                      ("savePath", savePath)));
 }
 private void WriteFile(BuildForm bf)
 {
     bf.DetailMessage("Saving " + SparkGlobals.OutputFile + ".");
     System.IO.File.WriteAllBytes(SparkGlobals.OutputFile, _final);
     bf.Progress(1.0);
 }
Beispiel #23
0
 public override (Uri url, HttpContent request) UninstallSearchPlugins(IEnumerable <string> names)
 {
     return(BuildForm(Url.UninstallSearchPlugins(),
                      ("names", string.Join("|", names))));
 }
Beispiel #24
0
 /// <summary>
 /// Create an <see cref="IFormDialog{T}"/> using the <see cref="BuildForm{T}"/> parameter.
 /// </summary>
 /// <typeparam name="T">The form type.</typeparam>
 /// <param name="buildForm">The delegate to build the form.</param>
 /// <param name="options">The form options.</param>
 /// <returns>The form dialog.</returns>
 public static IFormDialog <T> FromForm <T>(BuildForm <T> buildForm, FormOptions options = FormOptions.None) where T : class, new()
 {
     return(new FormDialog <T>(new T(), buildForm, options));
 }
Beispiel #25
0
 public override (Uri url, HttpContent request) EnableDisableSearchPlugins(IEnumerable <string> names, bool enable)
 {
     return(BuildForm(Url.EnableDisableSearchPlugins(),
                      ("names", string.Join("|", names)),
                      ("enable", enable.ToLowerString())));
 }
Beispiel #26
0
 public override (Uri url, HttpContent request) Recheck(IEnumerable <string> hashes)
 {
     return(BuildForm(Url.Recheck(),
                      ("hashes", JoinHashes(hashes))));
 }
Beispiel #27
0
 public override (Uri url, HttpContent request) InstallSearchPlugins(IEnumerable <Uri> sources)
 {
     return(BuildForm(Url.InstallSearchPlugins(),
                      ("sources", string.Join("|", sources.Select(u => u.AbsoluteUri)))));
 }
Beispiel #28
0
 public virtual (Uri url, HttpContent request) Login(string username, string password)
 {
     return(BuildForm(Url.Login(),
                      ("username", username),
                      ("password", password)));
 }
Beispiel #29
0
 public override (Uri url, HttpContent request) DeleteTrackers(string hash, IEnumerable <Uri> trackerUrls)
 {
     return(BuildForm(Url.DeleteTrackers(),
                      ("hash", hash),
                      ("urls", string.Join("|", trackerUrls.Select(u => u.AbsoluteUri)))));
 }
Beispiel #30
0
 internal PizzaOrderDialog(BuildForm <PizzaOrder> makePizzaForm)
 {
     this.MakePizzaForm = makePizzaForm;
 }
Beispiel #31
0
 public ResBuildCommandButton(BuildForm f)
 {
     par = f;
     Click += new EventHandler(CommandButtonClick);
 }