Skip to content

Commit

Permalink
Correction for issue # 4
Browse files Browse the repository at this point in the history
Correction for issue # 4
  • Loading branch information
MRGhidini committed Sep 28, 2018
1 parent 2c2fd56 commit b89f935
Showing 1 changed file with 78 additions and 24 deletions.
102 changes: 78 additions & 24 deletions SHM/Main.cs
@@ -1,4 +1,4 @@
using Microsoft.Win32;
using Microsoft.Win32;
using System;
using System.Collections.Generic;
using System.ComponentModel;
Expand Down Expand Up @@ -40,9 +40,9 @@ private void Main_Load(object sender, EventArgs e)
}

private void settingToolStripMenuItem_Click(object sender, EventArgs e)
{
OptionsSet o = new OptionsSet();
o.ShowDialog();
{
OptionsSet o = new OptionsSet();
o.ShowDialog();
}

private void rootToolStripMenuItem_Click(object sender, EventArgs e)
Expand Down Expand Up @@ -96,9 +96,10 @@ private void Psvita_CheckedChanged(object sender, EventArgs e)

Utilitary.CreateFolder(SetConfigRegistry.ReadRegistry(TypeRege.PathDownload.ToString()) + "\\HomeBrewDonwload\\" + "Psvita\\" + HomeBrewSelec.TitleId);

string Ex = HomeBrewSelec.LastDirectLink;
string Extension = Ex.Substring(Ex.Length - 4, 4);
string patharc = SetConfigRegistry.ReadRegistry(TypeRege.PathDownload.ToString()) + "\\HomeBrewDonwload\\" + "Psvita\\" + HomeBrewSelec.TitleId + "\\"+HomeBrewSelec.TitleName+ Extension;
//Find extension
string Ext = FindExten(HomeBrewSelec.LastDirectLink);

string patharc = SetConfigRegistry.ReadRegistry(TypeRege.PathDownload.ToString()) + "\\HomeBrewDonwload\\" + "Psvita\\" + HomeBrewSelec.TitleId + "\\"+HomeBrewSelec.TitleName+ Ext;
DownloadFile(HomeBrewSelec.LastDirectLink,patharc);
progressBar1.Visible = true;
label6.Visible = true;
Expand All @@ -107,7 +108,7 @@ private void Psvita_CheckedChanged(object sender, EventArgs e)
PS4.Enabled = false;
Psvita.Checked = false;

string NameArtTxt = SetConfigRegistry.ReadRegistry(TypeRege.PathDownload.ToString()) + "\\HomeBrewDonwload\\" + @"\historic.txt";
string NameArtTxt = SetConfigRegistry.ReadRegistry(TypeRege.PathDownload.ToString()) + "\\HomeBrewDonwload\\" + @"\historic.txt";
Utilitary.CreateFileWriteHistoric(NameArtTxt, HomeBrewSelec.TitleId);

}
Expand Down Expand Up @@ -152,9 +153,10 @@ private void PS3_CheckedChanged(object sender, EventArgs e)

Utilitary.CreateFolder(SetConfigRegistry.ReadRegistry(TypeRege.PathDownload.ToString()) + "\\HomeBrewDonwload\\" + "PS3\\" + HomeBrewSelec.TitleId);

string Ex = HomeBrewSelec.LastDirectLink;
string Extension = Ex.Substring(Ex.Length - 4, 4);
string patharc = SetConfigRegistry.ReadRegistry(TypeRege.PathDownload.ToString()) + "\\HomeBrewDonwload\\" + "PS3\\" + HomeBrewSelec.TitleId + "\\" + HomeBrewSelec.TitleName + Extension;
//Find extension
string Ext = FindExten(HomeBrewSelec.LastDirectLink);

string patharc = SetConfigRegistry.ReadRegistry(TypeRege.PathDownload.ToString()) + "\\HomeBrewDonwload\\" + "PS3\\" + HomeBrewSelec.TitleId + "\\" + HomeBrewSelec.TitleName + Ext;
DownloadFile(HomeBrewSelec.LastDirectLink, patharc);
progressBar1.Visible = true;
label6.Visible = true;
Expand All @@ -163,7 +165,7 @@ private void PS3_CheckedChanged(object sender, EventArgs e)
PS4.Enabled = false;
PS3.Checked = false;

string NameArtTxt = SetConfigRegistry.ReadRegistry(TypeRege.PathDownload.ToString()) + "\\HomeBrewDonwload\\" + @"\historic.txt";
string NameArtTxt = SetConfigRegistry.ReadRegistry(TypeRege.PathDownload.ToString()) + "\\HomeBrewDonwload\\" + @"\historic.txt";
Utilitary.CreateFileWriteHistoric(NameArtTxt, HomeBrewSelec.TitleId);
}
}
Expand Down Expand Up @@ -207,9 +209,10 @@ private void PS4_CheckedChanged(object sender, EventArgs e)

Utilitary.CreateFolder(SetConfigRegistry.ReadRegistry(TypeRege.PathDownload.ToString()) + "\\HomeBrewDonwload\\" + "PS4\\" + HomeBrewSelec.TitleId);

string Ex = HomeBrewSelec.LastDirectLink;
string Extension = Ex.Substring(Ex.Length - 4, 4);
string patharc = SetConfigRegistry.ReadRegistry(TypeRege.PathDownload.ToString()) + "\\HomeBrewDonwload\\" + "PS4\\" + HomeBrewSelec.TitleId + "\\" + HomeBrewSelec.TitleName + Extension;
//Find extension
string Ext = FindExten(HomeBrewSelec.LastDirectLink);

string patharc = SetConfigRegistry.ReadRegistry(TypeRege.PathDownload.ToString()) + "\\HomeBrewDonwload\\" + "PS4\\" + HomeBrewSelec.TitleId + "\\" + HomeBrewSelec.TitleName + Ext;
DownloadFile(HomeBrewSelec.LastDirectLink, patharc);
progressBar1.Visible = true;
label6.Visible = true;
Expand All @@ -218,33 +221,84 @@ private void PS4_CheckedChanged(object sender, EventArgs e)
PS4.Enabled = false;
PS4.Checked = false;

string NameArtTxt = SetConfigRegistry.ReadRegistry(TypeRege.PathDownload.ToString()) + "\\HomeBrewDonwload\\" + @"\historic.txt";
string NameArtTxt = SetConfigRegistry.ReadRegistry(TypeRege.PathDownload.ToString()) + "\\HomeBrewDonwload\\" + @"\historic.txt";
Utilitary.CreateFileWriteHistoric(NameArtTxt, HomeBrewSelec.TitleId);
}
}

public string FindExten (string pathweb)
{
string Ex = pathweb;
string Extension = Ex.Substring(Ex.Length - 4, 4);

if (Extension == ".vpk" || Extension == ".zip" || Extension == ".rar" || Extension == ".exe" || Extension == ".msi" || Extension == ".pkg" || Extension == ".bin")
{
return Extension;
}
else
{
MyWebClient MyWebRespo = new MyWebClient();
WebRequest WebRequesSite = WebRequest.Create(pathweb);
MyWebRespo.GetWebResponse(WebRequesSite);
string ext = MyWebRespo.GetWebResponse(WebRequesSite).ResponseUri.Query;
string[] ComplExt = ext.Split('.');

Extension = ComplExt[1].Substring(0, 3).ToString();
Extension = "." + Extension;

if (Extension == ".vpk" || Extension == ".zip" || Extension == ".rar" || Extension == ".exe" || Extension == ".msi" || Extension == ".pkg" || Extension == ".bin")
{
return Extension;
}
else
{
Extension = ".vpk";
}
}

return Extension;

}

class MyWebClient : WebClient
{
Uri _responseUri;

public Uri ResponseUri
{
get { return _responseUri; }
}

public WebResponse GetWebResponse(WebRequest request)
{
WebResponse response = base.GetWebResponse(request);
_responseUri = response.ResponseUri;
return response;
}
}

private static WebClient web = new WebClient();
public void DownloadFile(string url, string output)
{
WebClient web = new WebClient();

web.DownloadProgressChanged += new DownloadProgressChangedEventHandler(Web_DownloadProgressChanged);
web.DownloadFileCompleted += new System.ComponentModel.AsyncCompletedEventHandler(Web_DownloadFileCompleted);
web.DownloadFileAsync(new Uri(url), output);
{
WebClient web = new WebClient();

web.DownloadProgressChanged += new DownloadProgressChangedEventHandler(Web_DownloadProgressChanged);
web.DownloadFileCompleted += new System.ComponentModel.AsyncCompletedEventHandler(Web_DownloadFileCompleted);
web.DownloadFileAsync(new Uri(url), output);
}

public void Web_DownloadFileCompleted(object sender, System.ComponentModel.AsyncCompletedEventArgs e)
{
//throw new NotImplementedException();
if (e.Cancelled == true)
{
//FileSystem.DeleteFile(path + "PKG-h-encore\\xGMrXOkORxWRyqzLMihZPqsXAbAXLzvAdJFqtPJLAZTgOcqJobxQAhLNbgiFydVlcmVOrpZKklOYxizQCRpiLfjeROuWivGXfwgkq.pkg");
//xGMrXOkORxWRyqzLMihZPqsXAbAXLzvAdJFqtPJLAZTgOcqJobxQAhLNbgiFydVlcmVOrpZKklOYxizQCRpiLfjeROuWivGXfwgkq");
MessageBox.Show("Download canceled.", "Download canceled", MessageBoxButtons.OK, MessageBoxIcon.Information);

}
else if (e.Error != null) // We have an error! Retry a few times, then abort.
{
//FileSystem.DeleteFile(path + "PKG-h-encore\\xGMrXOkORxWRyqzLMihZPqsXAbAXLzvAdJFqtPJLAZTgOcqJobxQAhLNbgiFydVlcmVOrpZKklOYxizQCRpiLfjeROuWivGXfwgkq.pkg");
//xGMrXOkORxWRyqzLMihZPqsXAbAXLzvAdJFqtPJLAZTgOcqJobxQAhLNbgiFydVlcmVOrpZKklOYxizQCRpiLfjeROuWivGXfwgkq");
MessageBox.Show("An error ocurred while trying to download file: " + e.Error, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);

}
Expand Down

0 comments on commit b89f935

Please sign in to comment.