From 3775e0a9a4834131d78974b81d50384ea8af695e Mon Sep 17 00:00:00 2001 From: givememystuffplease Date: Thu, 8 Jul 2010 20:32:29 +0000 Subject: [PATCH] DSi/Wii server selection (NusClient) Progress bar updates status --- NUS Downloader/Form1.cs | 19 +++++++++++++++---- NUS Downloader/NusClient.cs | 14 +++++++++++++- 2 files changed, 28 insertions(+), 5 deletions(-) diff --git a/NUS Downloader/Form1.cs b/NUS Downloader/Form1.cs index 78fa705..0286447 100644 --- a/NUS Downloader/Form1.cs +++ b/NUS Downloader/Form1.cs @@ -41,9 +41,6 @@ namespace NUS_Downloader { public partial class Form1 : Form { - private const string WII_NUS_URL = "http://nus.cdn.shop.wii.com/ccs/download/"; - private const string DSI_NUS_URL = "http://nus.cdn.t.shop.nintendowifi.net/ccs/download/"; - private readonly string CURRENT_DIR = Directory.GetCurrentDirectory(); // TODO: Always remember to change version! @@ -440,7 +437,7 @@ namespace NUS_Downloader WriteStatus(String.Format(" Content {0}: {1} ({2} bytes)", a, tmdLocal.Contents[a].ContentID.ToString(), tmdLocal.Contents[a].Size.ToString())); WriteStatus(String.Format(" - Index: {0}", tmdLocal.Contents[a].Index.ToString())); WriteStatus(String.Format(" - Type: {0}", tmdLocal.Contents[a].Type.ToString())); - WriteStatus(String.Format(" - Hash: {0}...", DisplayBytes(tmdLocal.Contents[a].Hash, String.Empty).Substring(0, 8))); + WriteStatus(String.Format(" - Hash: {0}...", DisplayBytes(tmdLocal.Contents[a].Hash, String.Empty).Substring(0, 8))); } WriteStatus("TMD information parsed!"); @@ -868,7 +865,16 @@ namespace NUS_Downloader nusClient.ConfigureNusClient(nusWC); nusClient.UseLocalFiles = localuse.Checked; nusClient.ContinueWithoutTicket = true; + + // Server + if (consoleCBox.SelectedIndex == 0) + nusClient.SetToWiiServer(); + else if (consoleCBox.SelectedIndex == 1) + nusClient.SetToDSiServer(); + + // Events nusClient.Debug += new EventHandler(nusClient_Debug); + nusClient.Progress += new EventHandler(nusClient_Progress); libWiiSharp.StoreType[] storeTypes = new libWiiSharp.StoreType[3]; if (packbox.Checked) storeTypes[0] = libWiiSharp.StoreType.WAD; else storeTypes[0] = libWiiSharp.StoreType.Empty; @@ -894,6 +900,11 @@ namespace NUS_Downloader } + void nusClient_Progress(object sender, ProgressChangedEventArgs e) + { + dlprogress.Value = e.ProgressPercentage; + } + void nusClient_Debug(object sender, libWiiSharp.MessageEventArgs e) { WriteStatus(e.Message); diff --git a/NUS Downloader/NusClient.cs b/NUS Downloader/NusClient.cs index 68ffc7c..ebfa49a 100644 --- a/NUS Downloader/NusClient.cs +++ b/NUS Downloader/NusClient.cs @@ -34,7 +34,10 @@ namespace libWiiSharp public class NusClient : IDisposable { - private const string nusUrl = "http://nus.cdn.shop.wii.com/ccs/download/"; + private const string WII_NUS_URL = "http://nus.cdn.shop.wii.com/ccs/download/"; + private const string DSI_NUS_URL = "http://nus.cdn.t.shop.nintendowifi.net/ccs/download/"; + + private string nusUrl = WII_NUS_URL; private WebClient wcNus = new WebClient(); private bool useLocalFiles = false; private bool continueWithoutTicket = false; @@ -80,6 +83,15 @@ namespace libWiiSharp wcNus = wcReady; } + public void SetToWiiServer() + { + nusUrl = WII_NUS_URL; + } + + public void SetToDSiServer() + { + nusUrl = DSI_NUS_URL; + } /// /// Grabs a title from NUS, you can define several store types.