Implement #10051.
- Add a simple download progress meter to pkgman that prints a hash mark for every 2% of the download completed. Improvements welcome.
This commit is contained in:
@@ -27,7 +27,8 @@ PackageManager::PackageManager(BPackageInstallationLocation location)
|
|||||||
BPackageManager(location),
|
BPackageManager(location),
|
||||||
BPackageManager::UserInteractionHandler(),
|
BPackageManager::UserInteractionHandler(),
|
||||||
fDecisionProvider(),
|
fDecisionProvider(),
|
||||||
fClientInstallationInterface()
|
fClientInstallationInterface(),
|
||||||
|
fPreviousDownloadPercentage(0)
|
||||||
{
|
{
|
||||||
fInstallationInterface = &fClientInstallationInterface;
|
fInstallationInterface = &fClientInstallationInterface;
|
||||||
fUserInteractionHandler = this;
|
fUserInteractionHandler = this;
|
||||||
@@ -156,6 +157,7 @@ void
|
|||||||
PackageManager::ProgressPackageDownloadStarted(const char* packageName)
|
PackageManager::ProgressPackageDownloadStarted(const char* packageName)
|
||||||
{
|
{
|
||||||
printf("Downloading %s...\n", packageName);
|
printf("Downloading %s...\n", packageName);
|
||||||
|
fPreviousDownloadPercentage = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -163,14 +165,23 @@ void
|
|||||||
PackageManager::ProgressPackageDownloadActive(const char* packageName,
|
PackageManager::ProgressPackageDownloadActive(const char* packageName,
|
||||||
float completionPercentage)
|
float completionPercentage)
|
||||||
{
|
{
|
||||||
// TODO: how to report progress? ncurses perhaps?
|
int32 currentPercentage = int32(completionPercentage * 100);
|
||||||
|
int32 difference = currentPercentage - fPreviousDownloadPercentage;
|
||||||
|
|
||||||
|
while (difference >= 2) {
|
||||||
|
printf("#");
|
||||||
|
difference -= 2;
|
||||||
|
}
|
||||||
|
fflush(stdout);
|
||||||
|
|
||||||
|
fPreviousDownloadPercentage = currentPercentage - difference;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
PackageManager::ProgressPackageDownloadComplete(const char* packageName)
|
PackageManager::ProgressPackageDownloadComplete(const char* packageName)
|
||||||
{
|
{
|
||||||
printf("Finished downloading %s...\n", packageName);
|
printf("\nFinished downloading %s.\n", packageName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -67,6 +67,7 @@ private:
|
|||||||
DecisionProvider fDecisionProvider;
|
DecisionProvider fDecisionProvider;
|
||||||
BPackageManager::ClientInstallationInterface
|
BPackageManager::ClientInstallationInterface
|
||||||
fClientInstallationInterface;
|
fClientInstallationInterface;
|
||||||
|
int32 fPreviousDownloadPercentage;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user