Skip to content

Commit

Permalink
Remove NanaGet::Aria2TaskStatus and NanaGet::Aria2FileInformation.
Browse files Browse the repository at this point in the history
  • Loading branch information
MouriNaruto committed Jul 5, 2024
1 parent 3d8f9e5 commit 8955e6c
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 89 deletions.
49 changes: 2 additions & 47 deletions NanaGet/NanaGetCore.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -655,59 +655,14 @@ NanaGet::Aria2TaskInformation NanaGet::Aria2Instance::ParseTaskInformation(
NanaGet::Aria2TaskInformation Result;

Result.Gid = NanaGet::Aria2::FromDownloadGid(Information.Gid);
switch (Information.Status)
{
case NanaGet::Aria2::DownloadStatus::Active:
Result.Status = NanaGet::Aria2TaskStatus::Active;
break;
case NanaGet::Aria2::DownloadStatus::Waiting:
Result.Status = NanaGet::Aria2TaskStatus::Waiting;
break;
case NanaGet::Aria2::DownloadStatus::Paused:
Result.Status = NanaGet::Aria2TaskStatus::Paused;
break;
case NanaGet::Aria2::DownloadStatus::Complete:
Result.Status = NanaGet::Aria2TaskStatus::Complete;
break;
case NanaGet::Aria2::DownloadStatus::Removed:
Result.Status = NanaGet::Aria2TaskStatus::Removed;
break;
default:
Result.Status = NanaGet::Aria2TaskStatus::Error;
break;
}
Result.Status = Information.Status;
Result.TotalLength = Information.TotalLength;
Result.CompletedLength = Information.CompletedLength;
Result.DownloadSpeed = Information.DownloadSpeed;
Result.UploadSpeed = Information.UploadSpeed;
Result.InfoHash = Information.InfoHash;
Result.Dir = Information.Dir;
for (NanaGet::Aria2::FileInformation const& File : Information.Files)
{
NanaGet::Aria2FileInformation Current;
Current.Index = File.Index;
Current.Path = File.Path;
Current.Length = File.Length;
Current.CompletedLength = File.CompletedLength;
Current.Selected = File.Selected;
for (NanaGet::Aria2::UriInformation const& Uri : File.Uris)
{
NanaGet::Aria2UriInformation InnerCurrent;
InnerCurrent.Uri = Uri.Uri;
switch (Uri.Status)
{
case NanaGet::Aria2::UriStatus::Waiting:
InnerCurrent.Status = NanaGet::Aria2UriStatus::Waiting;
break;
default:
InnerCurrent.Status = NanaGet::Aria2UriStatus::Used;
break;
}

Current.Uris.emplace_back(InnerCurrent);
}
Result.Files.emplace_back(Current);
}
Result.Files = Information.Files;
Result.FriendlyName = NanaGet::Aria2::ToFriendlyName(Information);

return Result;
Expand Down
36 changes: 2 additions & 34 deletions NanaGet/NanaGetCore.h
Original file line number Diff line number Diff line change
Expand Up @@ -71,49 +71,17 @@ namespace NanaGet
winrt::hstring const& SubString,
bool IgnoreCase);

enum class Aria2UriStatus : std::int32_t
{
Used = 0,
Waiting = 1,
};

struct Aria2UriInformation
{
std::string Uri;
Aria2UriStatus Status;
};

struct Aria2FileInformation
{
std::uint64_t Index;
std::string Path;
std::uint64_t Length;
std::uint64_t CompletedLength;
bool Selected;
std::vector<Aria2UriInformation> Uris;
};

enum class Aria2TaskStatus : std::int32_t
{
Active = 0,
Waiting = 1,
Paused = 2,
Error = 3,
Complete = 4,
Removed = 5,
};

struct Aria2TaskInformation
{
std::string Gid;
Aria2TaskStatus Status;
NanaGet::Aria2::DownloadStatus Status;
std::uint64_t TotalLength;
std::uint64_t CompletedLength;
std::uint64_t DownloadSpeed;
std::uint64_t UploadSpeed;
std::string InfoHash;
std::string Dir;
std::vector<Aria2FileInformation> Files;
std::vector<NanaGet::Aria2::FileInformation> Files;
std::string FriendlyName;
};

Expand Down
16 changes: 8 additions & 8 deletions NanaGet/TaskItem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,9 @@ namespace winrt::NanaGet::implementation
hstring Result;

std::set<hstring> Uris;
for (Aria2FileInformation const& File : Information.Files)
for (NanaGet::Aria2::FileInformation const& File : Information.Files)
{
for (Aria2UriInformation const& Item : File.Uris)
for (NanaGet::Aria2::UriInformation const& Item : File.Uris)
{
Uris.emplace(winrt::to_hstring(Item.Uri));
}
Expand All @@ -62,22 +62,22 @@ namespace winrt::NanaGet::implementation

switch (Information.Status)
{
case Aria2TaskStatus::Active:
case NanaGet::Aria2::DownloadStatus::Active:
this->Status.Value = TaskStatus::Active;
break;
case Aria2TaskStatus::Waiting:
case NanaGet::Aria2::DownloadStatus::Waiting:
this->Status.Value = TaskStatus::Waiting;
break;
case Aria2TaskStatus::Paused:
case NanaGet::Aria2::DownloadStatus::Paused:
this->Status.Value = TaskStatus::Paused;
break;
case Aria2TaskStatus::Error:
case NanaGet::Aria2::DownloadStatus::Error:
this->Status.Value = TaskStatus::Error;
break;
case Aria2TaskStatus::Complete:
case NanaGet::Aria2::DownloadStatus::Complete:
this->Status.Value = TaskStatus::Complete;
break;
case Aria2TaskStatus::Removed:
case NanaGet::Aria2::DownloadStatus::Removed:
this->Status.Value = TaskStatus::Removed;
break;
default:
Expand Down

0 comments on commit 8955e6c

Please sign in to comment.