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")))); }
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))); }
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")))); }
public override (Uri url, HttpContent request) RenameFolder(string hash, string oldPath, string newPath) { return(BuildForm(Url.RenameFolder(), ("hash", hash), ("oldPath", oldPath), ("newPath", newPath))); }
public override (Uri url, HttpContent request) RenameFile(string hash, int fileId, string newName) { return(BuildForm(Url.RenameFile(), ("hash", hash), ("id", fileId.ToString()), ("name", newName))); }
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))); }
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); }
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); }
public override (Uri url, HttpContent request) DeleteTorrents(IEnumerable <string> hashes, bool withFiles) { return(BuildForm(Url.DeleteTorrents(withFiles), ("hashes", JoinHashes(hashes)), ("deleteFiles", withFiles.ToLowerString()))); }
public override (Uri url, HttpContent request) ResumeAll() { return(BuildForm(Url.ResumeAll(), ("hashes", "all"))); }
public override (Uri url, HttpContent request) DeleteSearch(int id) { return(BuildForm(Url.DeleteSearch(), ("id", id.ToString()))); }
public static IFormDialog <T> MakeForm <T>(BuildForm <T> buildForm) where T : class, new() { return(new FormDialog <T>(new T(), buildForm, options: FormOptions.PromptInStart)); }
private void BuildButton_Click(object sender, EventArgs e) { _buildForm = new BuildForm(); _buildForm.Show(ParentForm); }
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); }
public override (Uri url, HttpContent request) UninstallSearchPlugins(IEnumerable <string> names) { return(BuildForm(Url.UninstallSearchPlugins(), ("names", string.Join("|", names)))); }
/// <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)); }
public override (Uri url, HttpContent request) EnableDisableSearchPlugins(IEnumerable <string> names, bool enable) { return(BuildForm(Url.EnableDisableSearchPlugins(), ("names", string.Join("|", names)), ("enable", enable.ToLowerString()))); }
public override (Uri url, HttpContent request) Recheck(IEnumerable <string> hashes) { return(BuildForm(Url.Recheck(), ("hashes", JoinHashes(hashes)))); }
public override (Uri url, HttpContent request) InstallSearchPlugins(IEnumerable <Uri> sources) { return(BuildForm(Url.InstallSearchPlugins(), ("sources", string.Join("|", sources.Select(u => u.AbsoluteUri))))); }
public virtual (Uri url, HttpContent request) Login(string username, string password) { return(BuildForm(Url.Login(), ("username", username), ("password", password))); }
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))))); }
internal PizzaOrderDialog(BuildForm <PizzaOrder> makePizzaForm) { this.MakePizzaForm = makePizzaForm; }
public ResBuildCommandButton(BuildForm f) { par = f; Click += new EventHandler(CommandButtonClick); }