Skip to content

Commit

Permalink
SoftwareUpdater updates
Browse files Browse the repository at this point in the history
Bug fix- show correct version on package uninstall list item tooltip
Correct if else formatting
Use the BPackageManager FullSync() function instead of Update
Change warning strings in BPackageManager to sentence casing
Show list item tooltip on a mouse down (helps with touch devices)
  • Loading branch information
Brian Hill committed Mar 20, 2017
1 parent 8eee700 commit ab8f11b
Show file tree
Hide file tree
Showing 5 changed files with 57 additions and 47 deletions.
19 changes: 14 additions & 5 deletions src/apps/softwareupdater/SoftwareUpdaterWindow.cpp
Expand Up @@ -407,8 +407,7 @@ SoftwareUpdaterWindow::_SetState(uint32 state)
SetSizeLimits(defaultWidth, 9999,
fDefaultRect.Height() + 4 * fListView->ItemHeight(), 9999);
ResizeTo(defaultWidth, .75 * defaultWidth);
}
else if (fCurrentState == STATE_FINAL_MESSAGE) {
} else if (fCurrentState == STATE_FINAL_MESSAGE) {
fPackagesLayoutItem->SetVisible(false);
float defaultWidth = fDefaultRect.Width();
float defaultHeight = fDefaultRect.Height();
Expand All @@ -422,8 +421,7 @@ SoftwareUpdaterWindow::_SetState(uint32 state)
if (fCurrentState == STATE_DISPLAY_PROGRESS) {
fDetailsLayoutItem->SetVisible(false);
fProgressLayoutItem->SetVisible(true);
}
else {
} else {
fProgressLayoutItem->SetVisible(false);
fDetailsLayoutItem->SetVisible(true);
}
Expand Down Expand Up @@ -658,6 +656,17 @@ PackageListView::FrameResized(float newWidth, float newHeight)
}


void
PackageListView::MouseDown(BPoint where)
{
BOutlineListView::MouseDown(where);
BToolTip* tooltip = NULL;
bool found = GetToolTipAt(where, &tooltip);
if (found)
ShowToolTip(tooltip);
}


bool
PackageListView::GetToolTipAt(BPoint point, BToolTip** _tip)
{
Expand Down Expand Up @@ -731,7 +740,7 @@ PackageListView::AddPackage(uint32 install_type, const char* name,
version.SetTo("");
tooltip.Append(B_TRANSLATE_COMMENT("Uninstalling version",
"Tooltip text"))
.Append(" ").Append(new_ver);
.Append(" ").Append(cur_ver);
break;
}

Expand Down
3 changes: 2 additions & 1 deletion src/apps/softwareupdater/SoftwareUpdaterWindow.h
Expand Up @@ -87,7 +87,8 @@ class PackageItem : public BListItem {
class PackageListView : public BOutlineListView {
public:
PackageListView();
virtual void FrameResized(float newWidth, float newHeight);
virtual void FrameResized(float newWidth, float newHeight);
virtual void MouseDown(BPoint where);
void AddPackage(uint32 install_type,
const char* name,
const char* cur_ver,
Expand Down
7 changes: 4 additions & 3 deletions src/apps/softwareupdater/UpdateAction.cpp
Expand Up @@ -49,12 +49,13 @@ UpdateAction::Perform()
| BPackageManager::B_REFRESH_REPOSITORIES);

// These values indicate that all updates should be installed
int packageCount = 0;
const char* const packages = "";
//int packageCount = 0;
//const char* const packages = "";

// perform the update
// fUpdateManager->SetDebugLevel(1);
fUpdateManager->Update(&packages, packageCount);
//fUpdateManager->Update(&packages, packageCount);
fUpdateManager->FullSync();
} catch (BFatalErrorException ex) {
fUpdateManager->FinalUpdate(B_TRANSLATE("Updates did not complete"),
ex.Message());
Expand Down
8 changes: 3 additions & 5 deletions src/apps/softwareupdater/UpdateManager.cpp
Expand Up @@ -88,8 +88,7 @@ UpdateManager::CheckNetworkConnection()
BMessage reply;
messenger.SendMessage(&message, &reply);
reply.FindInt32(kKeyAlertResult, &result);
}
else {
} else {
BAlert* alert = new BAlert("network_connection",
B_TRANSLATE_COMMENT("No active network connection was found",
"Alert message"),
Expand Down Expand Up @@ -260,7 +259,7 @@ UpdateManager::Warn(status_t error, const char* format, ...)
va_list args;
va_start(args, format);
vfprintf(stderr, format, args);
vsnprintf(buffer, 256, format, args);
vsnprintf(buffer, sizeof(buffer), format, args);
va_end(args);

if (error == B_OK)
Expand All @@ -272,8 +271,7 @@ UpdateManager::Warn(status_t error, const char* format, ...)
if (fStatusWindow->UserCancelRequested())
throw BAbortedByUserException();
fStatusWindow->ShowWarningAlert(buffer);
}
else {
} else {
BString text("SoftwareUpdater:\n");
text.Append(buffer);
BAlert* alert = new BAlert("warning", text, B_TRANSLATE("OK"), NULL,
Expand Down
67 changes: 34 additions & 33 deletions src/kits/package/manager/PackageManager.cpp
Expand Up @@ -86,7 +86,7 @@ BPackageManager::Init(uint32 flags)
// create the solver
status_t error = BSolver::Create(fSolver);
if (error != B_OK)
DIE(error, "failed to create solver");
DIE(error, "Failed to create solver");

if (fSystemRepository == NULL || fHomeRepository == NULL
|| fLocalRepository == NULL) {
Expand Down Expand Up @@ -126,7 +126,7 @@ BPackageManager::Init(uint32 flags)
error = roster.GetRepositoryNames(repositoryNames);
if (error != B_OK) {
fUserInteractionHandler->Warn(error,
"failed to get repository names");
"Failed to get repository names");
}

int32 repositoryNameCount = repositoryNames.CountStrings();
Expand Down Expand Up @@ -168,10 +168,10 @@ BPackageManager::Install(const BSolverPackageSpecifierList& packages)
status_t error = fSolver->Install(packages, &unmatchedSpecifier);
if (error != B_OK) {
if (unmatchedSpecifier != NULL) {
DIE(error, "failed to find a match for \"%s\"",
DIE(error, "Failed to find a match for \"%s\"",
unmatchedSpecifier->SelectString().String());
} else
DIE(error, "failed to compute packages to install");
DIE(error, "Failed to compute packages to install");
}

_HandleProblems();
Expand Down Expand Up @@ -205,10 +205,10 @@ BPackageManager::Uninstall(const BSolverPackageSpecifierList& packages)
BSolver::B_FIND_INSTALLED_ONLY, foundPackages, &unmatchedSpecifier);
if (error != B_OK) {
if (unmatchedSpecifier != NULL) {
DIE(error, "failed to find a match for \"%s\"",
DIE(error, "Failed to find a match for \"%s\"",
unmatchedSpecifier->SelectString().String());
} else
DIE(error, "failed to compute packages to uninstall");
DIE(error, "Failed to compute packages to uninstall");
}

// determine the inverse base package closure for the found packages
Expand Down Expand Up @@ -237,7 +237,7 @@ BPackageManager::Uninstall(const BSolverPackageSpecifierList& packages)
for (;;) {
error = fSolver->VerifyInstallation(BSolver::B_VERIFY_ALLOW_UNINSTALL);
if (error != B_OK)
DIE(error, "failed to compute packages to uninstall");
DIE(error, "Failed to compute packages to uninstall");

_HandleProblems();

Expand Down Expand Up @@ -296,10 +296,10 @@ BPackageManager::Update(const BSolverPackageSpecifierList& packages)
&unmatchedSpecifier);
if (error != B_OK) {
if (unmatchedSpecifier != NULL) {
DIE(error, "failed to find a match for \"%s\"",
DIE(error, "Failed to find a match for \"%s\"",
unmatchedSpecifier->SelectString().String());
} else
DIE(error, "failed to compute packages to update");
DIE(error, "Failed to compute packages to update");
}

_HandleProblems();
Expand All @@ -320,7 +320,7 @@ BPackageManager::FullSync()
// solve
status_t error = fSolver->FullSync();
if (error != B_OK)
DIE(error, "failed to compute packages to synchronize");
DIE(error, "Failed to compute packages to synchronize");

_HandleProblems();

Expand All @@ -340,7 +340,7 @@ BPackageManager::VerifyInstallation()
for (;;) {
status_t error = fSolver->VerifyInstallation();
if (error != B_OK)
DIE(error, "failed to compute package dependencies");
DIE(error, "Failed to compute package dependencies");

_HandleProblems();

Expand All @@ -362,7 +362,7 @@ BPackageManager::InstalledRepository&
BPackageManager::InstallationRepository()
{
if (fInstalledRepositories.IsEmpty())
DIE("no installation repository");
DIE("No installation repository");

return *fInstalledRepositories.LastItem();
}
Expand Down Expand Up @@ -416,7 +416,7 @@ BPackageManager::_HandleProblems()

status_t error = fSolver->SolveAgain();
if (error != B_OK)
DIE(error, "failed to recompute packages to un/-install");
DIE(error, "Failed to recompute packages to un/-install");
}
}

Expand All @@ -427,7 +427,7 @@ BPackageManager::_AnalyzeResult()
BSolverResult result;
status_t error = fSolver->GetResult(result);
if (error != B_OK)
DIE(error, "failed to compute packages to un/-install");
DIE(error, "Failed to compute packages to un/-install");

InstalledRepository& installationRepository = InstallationRepository();
PackageList& packagesToActivate
Expand Down Expand Up @@ -537,7 +537,7 @@ BPackageManager::_PreparePackageChanges(

status_t error = fInstallationInterface->PrepareTransaction(*transaction);
if (error != B_OK)
DIE(error, "failed to create transaction");
DIE(error, "Failed to create transaction");

// download the new packages and prepare the transaction
for (int32 i = 0; BSolverPackage* package = packagesToActivate.ItemAt(i);
Expand All @@ -551,7 +551,7 @@ BPackageManager::_PreparePackageChanges(
BEntry entry;
error = entry.SetTo(&transaction->TransactionDirectory(), fileName);
if (error != B_OK)
DIE(error, "failed to create package entry");
DIE(error, "Failed to create package entry");

RemoteRepository* remoteRepository
= dynamic_cast<RemoteRepository*>(package->Repository());
Expand All @@ -563,13 +563,14 @@ BPackageManager::_PreparePackageChanges(
status_t error = DownloadPackage(url, entry,
package->Info().Checksum());
if (error != B_OK)
DIE(error, "failed to download package");
DIE(error, "Failed to download package %s",
package->Info().Name().String());
} else if (package->Repository() != &installationRepository) {
// clone the existing package
LocalRepository* localRepository
= dynamic_cast<LocalRepository*>(package->Repository());
if (localRepository == NULL) {
DIE("internal error: repository %s is not a local repository",
DIE("Internal error: repository %s is not a local repository",
package->Repository()->Name().String());
}
_ClonePackageFile(localRepository, package, entry);
Expand Down Expand Up @@ -606,7 +607,7 @@ BPackageManager::_CommitPackageChanges(Transaction& transaction)
status_t error = fInstallationInterface->CommitTransaction(transaction,
transactionResult);
if (error != B_OK)
DIE(error, "failed to commit transaction");
DIE(error, "Failed to commit transaction");
if (transactionResult.Error() != B_TRANSACTION_OK)
DIE(transactionResult);

Expand All @@ -618,7 +619,7 @@ BPackageManager::_CommitPackageChanges(Transaction& transaction)
.GetEntry(&transactionDirectoryEntry)) != B_OK
|| (error = transactionDirectoryEntry.Remove()) != B_OK) {
fUserInteractionHandler->Warn(error,
"failed to remove transaction directory");
"Failed to remove transaction directory");
}

fUserInteractionHandler->ProgressApplyingChangesDone(
Expand All @@ -637,15 +638,15 @@ BPackageManager::_ClonePackageFile(LocalRepository* repository,
BPath destinationPath;
status_t error = entry.GetPath(&destinationPath);
if (error != B_OK) {
DIE(error, "failed to entry path of package file to install \"%s\"",
DIE(error, "Failed to entry path of package file to install \"%s\"",
package->Info().FileName().String());
}

// Copy the package. Ideally we would just hard-link it, but BFS doesn't
// support that.
error = BCopyEngine().CopyEntry(sourcePath.Path(), destinationPath.Path());
if (error != B_OK)
DIE(error, "failed to copy package file \"%s\"", sourcePath.Path());
DIE(error, "Failed to copy package file \"%s\"", sourcePath.Path());
}


Expand All @@ -668,7 +669,7 @@ BPackageManager::_FindBasePackage(const PackageList& packages,
}

if (basePackage == NULL) {
fUserInteractionHandler->Warn(B_OK, "package %s-%s doesn't have a "
fUserInteractionHandler->Warn(B_OK, "Package %s-%s doesn't have a "
"matching requires for its base package \"%s\"",
info.Name().String(), info.Version().ToString().String(),
info.BasePackage().String());
Expand Down Expand Up @@ -711,15 +712,15 @@ BPackageManager::_AddRemoteRepository(BPackageRoster& roster, const char* name,
status_t error = roster.GetRepositoryConfig(name, &config);
if (error != B_OK) {
fUserInteractionHandler->Warn(error,
"failed to get config for repository \"%s\". Skipping.", name);
"Failed to get config for repository \"%s\". Skipping.", name);
return;
}

BRepositoryCache cache;
error = _GetRepositoryCache(roster, config, refresh, cache);
if (error != B_OK) {
fUserInteractionHandler->Warn(error,
"failed to get cache for repository \"%s\". Skipping.", name);
"Failed to get cache for repository \"%s\". Skipping.", name);
return;
}

Expand All @@ -744,7 +745,7 @@ BPackageManager::_GetRepositoryCache(BPackageRoster& roster,
status_t error = RefreshRepository(config);
if (error != B_OK) {
fUserInteractionHandler->Warn(error,
"refreshing repository \"%s\" failed", config.Name().String());
"Refreshing repository \"%s\" failed", config.Name().String());
}

return roster.GetRepositoryCache(config.Name(), &_cache);
Expand Down Expand Up @@ -893,13 +894,13 @@ BPackageManager::MiscLocalRepository::GetPackagePath(BSolverPackage* package,
{
PackagePathMap::const_iterator it = fPackagePaths.find(package);
if (it == fPackagePaths.end()) {
DIE("package %s not in local repository",
DIE("Package %s not in local repository",
package->VersionedName().String());
}

status_t error = _path.SetTo(it->second.c_str());
if (error != B_OK)
DIE(error, "failed to init package path %s", it->second.c_str());
DIE(error, "Failed to init package path %s", it->second.c_str());
}


Expand Down Expand Up @@ -933,14 +934,14 @@ BPackageManager::InstalledRepository::GetPackagePath(BSolverPackage* package,
packagesWhich = B_USER_PACKAGES_DIRECTORY;
break;
default:
DIE("don't know packages directory path for installation location "
DIE("Don't know packages directory path for installation location "
"\"%s\"", Name().String());
}

BString fileName(package->Info().FileName());
status_t error = find_directory(packagesWhich, &_path);
if (error != B_OK || (error = _path.Append(fileName)) != B_OK) {
DIE(error, "failed to get path of package file \"%s\" in installation "
DIE(error, "Failed to get path of package file \"%s\" in installation "
"location \"%s\"", fileName.String(), Name().String());
}
}
Expand All @@ -950,10 +951,10 @@ void
BPackageManager::InstalledRepository::DisablePackage(BSolverPackage* package)
{
if (fDisabledPackages.HasItem(package))
DIE("package %s already disabled", package->VersionedName().String());
DIE("Package %s already disabled", package->VersionedName().String());

if (package->Repository() != this) {
DIE("package %s not in repository %s",
DIE("Package %s not in repository %s",
package->VersionedName().String(), Name().String());
}

Expand Down Expand Up @@ -994,7 +995,7 @@ BPackageManager::InstalledRepository::ApplyChanges()
i++) {
status_t error = AddPackage(package->Info());
if (error != B_OK) {
DIE(error, "failed to add package %s to %s repository",
DIE(error, "Failed to add package %s to %s repository",
package->Name().String(), Name().String());
}
}
Expand Down

0 comments on commit ab8f11b

Please sign in to comment.