diff options
| author | Michael <[email protected]> | 2017-02-02 17:11:14 -0500 |
|---|---|---|
| committer | Michael <[email protected]> | 2017-02-02 17:11:14 -0500 |
| commit | d5ab22629ba39ac9f0fae6768b527e82670f96fc (patch) | |
| tree | 49218d165b993edb47187b64d7ee932f108e442b /ShiftOS.WinForms/Applications/Shiftnet.cs | |
| parent | 44c1e66dd09d39773e329f138d11946e516a5308 (diff) | |
| download | shiftos_thereturn-d5ab22629ba39ac9f0fae6768b527e82670f96fc.tar.gz shiftos_thereturn-d5ab22629ba39ac9f0fae6768b527e82670f96fc.tar.bz2 shiftos_thereturn-d5ab22629ba39ac9f0fae6768b527e82670f96fc.zip | |
Implement the Downloader
Diffstat (limited to 'ShiftOS.WinForms/Applications/Shiftnet.cs')
| -rw-r--r-- | ShiftOS.WinForms/Applications/Shiftnet.cs | 53 |
1 files changed, 46 insertions, 7 deletions
diff --git a/ShiftOS.WinForms/Applications/Shiftnet.cs b/ShiftOS.WinForms/Applications/Shiftnet.cs index eebebd9..6f99d25 100644 --- a/ShiftOS.WinForms/Applications/Shiftnet.cs +++ b/ShiftOS.WinForms/Applications/Shiftnet.cs @@ -102,15 +102,54 @@ namespace ShiftOS.WinForms.Applications public void ShiftnetNavigate(string Url, bool pushHistory = true) { - if (!string.IsNullOrEmpty(CurrentUrl) && pushHistory) - History.Push(CurrentUrl); - CurrentUrl = Url; + - ServerManager.SendMessage("shiftnet_get", JsonConvert.SerializeObject(new + if (Url.EndsWith(".rnp") || !Url.Contains(".")) { - url = Url - })); - txturl.Text = Url; + if (!string.IsNullOrEmpty(CurrentUrl) && pushHistory) + History.Push(CurrentUrl); + CurrentUrl = Url; + ServerManager.SendMessage("shiftnet_get", JsonConvert.SerializeObject(new + { + url = Url + })); + txturl.Text = Url; + + } + else + { + ServerMessageReceived smr = null; + smr = (msg) => + { + if(msg.Name == "download_meta") + { + var bytes = JsonConvert.DeserializeObject<byte[]>(msg.Contents); + string destPath = null; + string ext = Url.Split('.')[Url.Split('.').Length - 1]; + + FileSkimmerBackend.GetFile(new[] { ext }, FileOpenerStyle.Save, new Action<string>((file) => + { + destPath = file; + })); + while (string.IsNullOrEmpty(destPath)) + { + + } + var d = new Download + { + ShiftnetUrl = Url, + Destination = destPath, + Bytes = bytes, + Progress = 0, + }; + DownloadManager.StartDownload(d); + AppearanceManager.SetupWindow(new Downloader()); + ServerManager.MessageReceived -= smr; + } + }; + ServerManager.MessageReceived += smr; + ServerManager.SendMessage("download_start", Url); + } } public void OnLoad() |
