Skip to content

Commit

Permalink
Paid Packages
Browse files Browse the repository at this point in the history
This adds abilty download paid packages using UDID.
  • Loading branch information
PythEch committed May 1, 2014
1 parent 32e7c49 commit dd45931
Show file tree
Hide file tree
Showing 5 changed files with 220 additions and 63 deletions.
28 changes: 18 additions & 10 deletions Cygnus/MainForm.APT.cs
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ public partial class MainForm
/// Used to download packages simultaneously.
/// Stores the first Uri in the queue.
/// </summary>
private static List<DownloadQueue> allQueues = new List<DownloadQueue> { };
private static List<Queue> allQueues = new List<Queue> { };

private static bool isDownloadCanceled = false;

Expand Down Expand Up @@ -240,6 +240,16 @@ private static bool RemoteUriExists(Uri url)
}
}

private string GetUDID()
{
if (!this.txtUDID.Text.IsNullOrWhitespace() && this.txtUDID.Text.Length == 40)
{
return this.txtUDID.Text;
}
// else ...
return "0000000000000000000000000000000000000000";
}

/// <summary>
/// Downloads a file from web using an URL and a Stream.
/// </summary>
Expand All @@ -253,8 +263,6 @@ private static void DownloadFile(Uri uri, Stream stream)
////request.Headers.Add("X-Firmware", "7.0.2");
////request.Headers.Add("X-Machine", "iPhone6,2");
request.Headers.Add("X-Unique-ID", "0000000000000000000000000000000000000000");
//some repos require this for some reason
//TODO: use pseudo-random ID to prevent being banned from some repos in the future

try
{
Expand Down Expand Up @@ -294,12 +302,12 @@ private static void DownloadFile(Uri uri, string path)
/// </summary>
/// <param name="uri">The URL to download.</param>
/// <param name="path">The path where the file's going to be downloaded.</param>
private void DownloadFileAndReportProgress(Uri uri, string path, string packageName, Cell progressBarCell)
private void DownloadQueue(Uri uri, string path, string packageName, Cell progressBarCell)
{
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(uri);
request.Method = WebRequestMethods.Http.Get;
request.UserAgent = "Telesphoreo APT-HTTP/1.0.592";
request.Headers.Add("X-Unique-ID", "0000000000000000000000000000000000000000");
request.Headers.Add("X-Unique-ID", GetUDID());

try
{
Expand Down Expand Up @@ -691,7 +699,7 @@ private void DownloadAllDependencies(Package pack, string dirPath)
Uri uri = new Uri(new Uri(dependencyPack.Repo.URL), dependencyPack.Filename);

// Add to queue
////DownloadQueue queue = UpdateQueueTable(pack.Name, uri);
////Queue queue = UpdateQueueTable(pack.Name, uri);
////allQueues.Add(queue);

string downloadPath = Path.Combine(dirPath, Path.GetFileName(uri.LocalPath));
Expand All @@ -700,7 +708,7 @@ private void DownloadAllDependencies(Package pack, string dirPath)

DownloadFile(uri, downloadPath);

////DownloadFileAndReportProgress(uri, downloadPath, pack.Name, queue.TableRow.Cells[1]);
////DownloadQueue(uri, downloadPath, pack.Name, queue.TableRow.Cells[1]);

DownloadAllDependencies(dependencyPack, dirPath); //yay! recursion
}
Expand Down Expand Up @@ -855,7 +863,7 @@ private struct FastPackage
#endregion Fields
}

private class DownloadQueue
private class Queue
{
#region Fields

Expand All @@ -874,9 +882,9 @@ private class DownloadQueue
public override bool Equals(object obj)
{
if (obj == null) return false;
if (!(obj is DownloadQueue)) return false;
if (!(obj is Queue)) return false;
DownloadQueue other = (DownloadQueue)obj;
Queue other = (Queue)obj;
return other.DownloadUri == DownloadUri && other.TableRow == TableRow;
}*/
Expand Down
197 changes: 169 additions & 28 deletions Cygnus/MainForm.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

1 comment on commit dd45931

@PythEch
Copy link
Owner Author

@PythEch PythEch commented on dd45931 May 1, 2014

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I meant "This adds ability to download paid packages using UDID." I was on a rush...

Please sign in to comment.