From a95820aae057c1281bd566744cd0b58f5f106d85 Mon Sep 17 00:00:00 2001
From: Humdinger <humdingerb@gmail.com>
Date: Sat, 8 Jul 2017 18:51:04 +0200
Subject: [PATCH] Package daemon notifications
* Sentence casing
* Adding package daemon icon to notifications
* Localize notification texts in the package kit
* Have "Package daemon" as group name and "Warning" as title
* Use ::BPrivate in Bitmap.h to solve an ambiguity (as pointed out
by PulkoMandy.
Fixes #13590.
---
headers/os/interface/Bitmap.h | 2 +-
src/kits/package/Jamfile | 6 ++++++
src/kits/package/manager/PackageManager.cpp | 24 ++++++++++++++----------
src/servers/package/Jamfile | 1 +
src/servers/package/PackageManager.cpp | 26 ++++++++++++++++++++++++--
src/servers/package/PackageManager.h | 3 +++
6 files changed, 49 insertions(+), 13 deletions(-)
diff --git a/headers/os/interface/Bitmap.h b/headers/os/interface/Bitmap.h
index d519166..aa58019 100644
a
|
b
|
public:
|
114 | 114 | private: |
115 | 115 | friend class BView; |
116 | 116 | friend class BApplication; |
117 | | friend class BPrivate::BPrivateScreen; |
| 117 | friend class ::BPrivate::BPrivateScreen; |
118 | 118 | friend class Private; |
119 | 119 | |
120 | 120 | virtual status_t Perform(perform_code d, void* arg); |
diff --git a/src/kits/package/Jamfile b/src/kits/package/Jamfile
index 9063876..dd9a0d11 100644
a
|
b
|
for architectureObject in [ MultiArchSubDirSetup ] {
|
143 | 143 | } |
144 | 144 | |
145 | 145 | HaikuSubInclude solver ; |
| 146 | |
| 147 | DoCatalogs libpackage.so |
| 148 | x-vnd.Haiku-libpackage |
| 149 | : |
| 150 | PackageManager.cpp |
| 151 | ; |
diff --git a/src/kits/package/manager/PackageManager.cpp b/src/kits/package/manager/PackageManager.cpp
index 4cafea4..a5fc8db 100644
a
|
b
|
|
10 | 10 | |
11 | 11 | #include <package/manager/PackageManager.h> |
12 | 12 | |
| 13 | #include <Catalog.h> |
13 | 14 | #include <Directory.h> |
14 | 15 | #include <package/CommitTransactionResult.h> |
15 | 16 | #include <package/DownloadFileRequest.h> |
… |
… |
|
32 | 33 | |
33 | 34 | #include "PackageManagerUtils.h" |
34 | 35 | |
| 36 | #undef B_TRANSLATION_CONTEXT |
| 37 | #define B_TRANSLATION_CONTEXT "PackageManagerKit" |
| 38 | |
35 | 39 | |
36 | 40 | using BPackageKit::BPrivate::FetchFileJob; |
37 | 41 | using BPackageKit::BPrivate::ValidateChecksumJob; |
… |
… |
BPackageManager::Init(uint32 flags)
|
126 | 130 | error = roster.GetRepositoryNames(repositoryNames); |
127 | 131 | if (error != B_OK) { |
128 | 132 | fUserInteractionHandler->Warn(error, |
129 | | "Failed to get repository names"); |
| 133 | B_TRANSLATE("Failed to get repository names")); |
130 | 134 | } |
131 | 135 | |
132 | 136 | int32 repositoryNameCount = repositoryNames.CountStrings(); |
… |
… |
BPackageManager::_CommitPackageChanges(Transaction& transaction)
|
619 | 623 | .GetEntry(&transactionDirectoryEntry)) != B_OK |
620 | 624 | || (error = transactionDirectoryEntry.Remove()) != B_OK) { |
621 | 625 | fUserInteractionHandler->Warn(error, |
622 | | "Failed to remove transaction directory"); |
| 626 | B_TRANSLATE("Failed to remove transaction directory")); |
623 | 627 | } |
624 | 628 | |
625 | 629 | fUserInteractionHandler->ProgressApplyingChangesDone( |
… |
… |
BPackageManager::_FindBasePackage(const PackageList& packages,
|
669 | 673 | } |
670 | 674 | |
671 | 675 | if (basePackage == NULL) { |
672 | | fUserInteractionHandler->Warn(B_OK, "Package %s-%s doesn't have a " |
673 | | "matching requires for its base package \"%s\"", |
| 676 | fUserInteractionHandler->Warn(B_OK, B_TRANSLATE("Package %s-%s " |
| 677 | "doesn't have a matching requires for its base package \"%s\""), |
674 | 678 | info.Name().String(), info.Version().ToString().String(), |
675 | 679 | info.BasePackage().String()); |
676 | 680 | return -1; |
… |
… |
BPackageManager::_AddRemoteRepository(BPackageRoster& roster, const char* name,
|
711 | 715 | BRepositoryConfig config; |
712 | 716 | status_t error = roster.GetRepositoryConfig(name, &config); |
713 | 717 | if (error != B_OK) { |
714 | | fUserInteractionHandler->Warn(error, |
715 | | "Failed to get config for repository \"%s\". Skipping.", name); |
| 718 | fUserInteractionHandler->Warn(error, B_TRANSLATE( |
| 719 | "Failed to get config for repository \"%s\". Skipping."), name); |
716 | 720 | return; |
717 | 721 | } |
718 | 722 | |
719 | 723 | BRepositoryCache cache; |
720 | 724 | error = _GetRepositoryCache(roster, config, refresh, cache); |
721 | 725 | if (error != B_OK) { |
722 | | fUserInteractionHandler->Warn(error, |
723 | | "Failed to get cache for repository \"%s\". Skipping.", name); |
| 726 | fUserInteractionHandler->Warn(error, B_TRANSLATE( |
| 727 | "Failed to get cache for repository \"%s\". Skipping."), name); |
724 | 728 | return; |
725 | 729 | } |
726 | 730 | |
… |
… |
BPackageManager::_GetRepositoryCache(BPackageRoster& roster,
|
744 | 748 | |
745 | 749 | status_t error = RefreshRepository(config); |
746 | 750 | if (error != B_OK) { |
747 | | fUserInteractionHandler->Warn(error, |
748 | | "Refreshing repository \"%s\" failed", config.Name().String()); |
| 751 | fUserInteractionHandler->Warn(error, B_TRANSLATE( |
| 752 | "Refreshing repository \"%s\" failed"), config.Name().String()); |
749 | 753 | } |
750 | 754 | |
751 | 755 | return roster.GetRepositoryCache(config.Name(), &_cache); |
diff --git a/src/servers/package/Jamfile b/src/servers/package/Jamfile
index ee33ef7..1c0e5c9 100644
a
|
b
|
Server package_daemon
|
33 | 33 | DoCatalogs package_daemon : |
34 | 34 | x-vnd.haiku-package_daemon |
35 | 35 | : |
| 36 | PackageManager.cpp |
36 | 37 | ProblemWindow.cpp |
37 | 38 | ResultWindow.cpp |
38 | 39 | ; |
diff --git a/src/servers/package/PackageManager.cpp b/src/servers/package/PackageManager.cpp
index adaffff..77d9486 100644
a
|
b
|
|
6 | 6 | |
7 | 7 | #include "PackageManager.h" |
8 | 8 | |
| 9 | #include <Catalog.h> |
| 10 | #include <NodeInfo.h> |
9 | 11 | #include <Notification.h> |
10 | 12 | #include <package/DownloadFileRequest.h> |
11 | 13 | #include <package/RefreshRepositoryRequest.h> |
… |
… |
|
13 | 15 | #include <package/solver/SolverPackageSpecifierList.h> |
14 | 16 | #include <package/solver/SolverProblem.h> |
15 | 17 | #include <package/solver/SolverProblemSolution.h> |
| 18 | #include <Roster.h> |
16 | 19 | |
17 | 20 | #include <AutoDeleter.h> |
18 | 21 | #include <package/manager/Exceptions.h> |
… |
… |
|
24 | 27 | #include "Root.h" |
25 | 28 | #include "Volume.h" |
26 | 29 | |
| 30 | #undef B_TRANSLATION_CONTEXT |
| 31 | #define B_TRANSLATION_CONTEXT "PackageManager" |
27 | 32 | |
28 | 33 | using BPackageKit::BManager::BPrivate::BAbortedByUserException; |
29 | 34 | using BPackageKit::BManager::BPrivate::BFatalErrorException; |
30 | 35 | using BPackageKit::BManager::BPrivate::BRepositoryBuilder; |
31 | 36 | |
32 | | |
33 | 37 | PackageManager::PackageManager(Root* root, Volume* volume) |
34 | 38 | : |
35 | 39 | BPackageManager(volume->Location(), this, this), |
… |
… |
PackageManager::Warn(status_t error, const char* format, ...)
|
306 | 310 | message << BString().SetToFormat(": %s", strerror(error)); |
307 | 311 | |
308 | 312 | BNotification notification(B_ERROR_NOTIFICATION); |
309 | | notification.SetTitle("Package Daemon"); |
| 313 | notification.SetGroup(B_TRANSLATE("Package daemon")); |
| 314 | notification.SetTitle(B_TRANSLATE("Warning")); |
310 | 315 | notification.SetContent(message); |
| 316 | BBitmap icon(_GetIcon()); |
| 317 | if (icon.IsValid()) |
| 318 | notification.SetIcon(&icon); |
311 | 319 | notification.Send(); |
312 | 320 | } |
313 | 321 | |
… |
… |
PackageManager::_InitGui()
|
404 | 412 | if (server == NULL || server->InitGUIContext() != B_OK) |
405 | 413 | throw BFatalErrorException("failed to initialize the GUI"); |
406 | 414 | } |
| 415 | |
| 416 | |
| 417 | BBitmap |
| 418 | PackageManager::_GetIcon() |
| 419 | { |
| 420 | int32 iconSize = B_LARGE_ICON; |
| 421 | BBitmap icon(BRect(0, 0, iconSize - 1, iconSize - 1), 0, B_RGBA32); |
| 422 | team_info teamInfo; |
| 423 | get_team_info(B_CURRENT_TEAM, &teamInfo); |
| 424 | app_info appInfo; |
| 425 | be_roster->GetRunningAppInfo(teamInfo.team, &appInfo); |
| 426 | BNodeInfo::GetTrackerIcon(&appInfo.ref, &icon, icon_size(iconSize)); |
| 427 | return icon; |
| 428 | } |
diff --git a/src/servers/package/PackageManager.h b/src/servers/package/PackageManager.h
index 123890d..e006c3a 100644
a
|
b
|
|
9 | 9 | #include <map> |
10 | 10 | #include <set> |
11 | 11 | |
| 12 | #include <Bitmap.h> |
12 | 13 | #include <package/Context.h> |
13 | 14 | #include <package/Job.h> |
14 | 15 | |
… |
… |
private:
|
99 | 100 | |
100 | 101 | void _InitGui(); |
101 | 102 | |
| 103 | BBitmap _GetIcon(); |
| 104 | |
102 | 105 | private: |
103 | 106 | Root* fRoot; |
104 | 107 | Volume* fVolume; |