Ticket #13590: 0002-Package-daemon-notifications.patch

File 0002-Package-daemon-notifications.patch, 7.6 KB (added by humdinger, 3 years ago)

new patch that actually builds

  • headers/os/interface/Bitmap.h

    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:  
    114114private:
    115115    friend class BView;
    116116    friend class BApplication;
    117     friend class BPrivate::BPrivateScreen;
     117    friend class ::BPrivate::BPrivateScreen;
    118118    friend class Private;
    119119
    120120    virtual status_t            Perform(perform_code d, void* arg);
  • src/kits/package/Jamfile

    diff --git a/src/kits/package/Jamfile b/src/kits/package/Jamfile
    index 9063876..dd9a0d11 100644
    a b for architectureObject in [ MultiArchSubDirSetup ] {  
    143143}
    144144
    145145HaikuSubInclude solver ;
     146
     147DoCatalogs libpackage.so
     148    x-vnd.Haiku-libpackage
     149    :
     150    PackageManager.cpp
     151;
  • src/kits/package/manager/PackageManager.cpp

    diff --git a/src/kits/package/manager/PackageManager.cpp b/src/kits/package/manager/PackageManager.cpp
    index 4cafea4..a5fc8db 100644
    a b  
    1010
    1111#include <package/manager/PackageManager.h>
    1212
     13#include <Catalog.h>
    1314#include <Directory.h>
    1415#include <package/CommitTransactionResult.h>
    1516#include <package/DownloadFileRequest.h>
     
    3233
    3334#include "PackageManagerUtils.h"
    3435
     36#undef B_TRANSLATION_CONTEXT
     37#define B_TRANSLATION_CONTEXT "PackageManagerKit"
     38
    3539
    3640using BPackageKit::BPrivate::FetchFileJob;
    3741using BPackageKit::BPrivate::ValidateChecksumJob;
    BPackageManager::Init(uint32 flags)  
    126130        error = roster.GetRepositoryNames(repositoryNames);
    127131        if (error != B_OK) {
    128132            fUserInteractionHandler->Warn(error,
    129                 "Failed to get repository names");
     133                B_TRANSLATE("Failed to get repository names"));
    130134        }
    131135
    132136        int32 repositoryNameCount = repositoryNames.CountStrings();
    BPackageManager::_CommitPackageChanges(Transaction& transaction)  
    619623            .GetEntry(&transactionDirectoryEntry)) != B_OK
    620624        || (error = transactionDirectoryEntry.Remove()) != B_OK) {
    621625        fUserInteractionHandler->Warn(error,
    622             "Failed to remove transaction directory");
     626            B_TRANSLATE("Failed to remove transaction directory"));
    623627    }
    624628
    625629    fUserInteractionHandler->ProgressApplyingChangesDone(
    BPackageManager::_FindBasePackage(const PackageList& packages,  
    669673    }
    670674
    671675    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\""),
    674678            info.Name().String(), info.Version().ToString().String(),
    675679            info.BasePackage().String());
    676680        return -1;
    BPackageManager::_AddRemoteRepository(BPackageRoster& roster, const char* name,  
    711715    BRepositoryConfig config;
    712716    status_t error = roster.GetRepositoryConfig(name, &config);
    713717    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);
    716720        return;
    717721    }
    718722
    719723    BRepositoryCache cache;
    720724    error = _GetRepositoryCache(roster, config, refresh, cache);
    721725    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);
    724728        return;
    725729    }
    726730
    BPackageManager::_GetRepositoryCache(BPackageRoster& roster,  
    744748
    745749    status_t error = RefreshRepository(config);
    746750    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());
    749753    }
    750754
    751755    return roster.GetRepositoryCache(config.Name(), &_cache);
  • src/servers/package/Jamfile

    diff --git a/src/servers/package/Jamfile b/src/servers/package/Jamfile
    index ee33ef7..1c0e5c9 100644
    a b Server package_daemon  
    3333DoCatalogs package_daemon :
    3434    x-vnd.haiku-package_daemon
    3535    :
     36    PackageManager.cpp
    3637    ProblemWindow.cpp
    3738    ResultWindow.cpp
    3839;
  • src/servers/package/PackageManager.cpp

    diff --git a/src/servers/package/PackageManager.cpp b/src/servers/package/PackageManager.cpp
    index adaffff..77d9486 100644
    a b  
    66
    77#include "PackageManager.h"
    88
     9#include <Catalog.h>
     10#include <NodeInfo.h>
    911#include <Notification.h>
    1012#include <package/DownloadFileRequest.h>
    1113#include <package/RefreshRepositoryRequest.h>
     
    1315#include <package/solver/SolverPackageSpecifierList.h>
    1416#include <package/solver/SolverProblem.h>
    1517#include <package/solver/SolverProblemSolution.h>
     18#include <Roster.h>
    1619
    1720#include <AutoDeleter.h>
    1821#include <package/manager/Exceptions.h>
     
    2427#include "Root.h"
    2528#include "Volume.h"
    2629
     30#undef B_TRANSLATION_CONTEXT
     31#define B_TRANSLATION_CONTEXT "PackageManager"
    2732
    2833using BPackageKit::BManager::BPrivate::BAbortedByUserException;
    2934using BPackageKit::BManager::BPrivate::BFatalErrorException;
    3035using BPackageKit::BManager::BPrivate::BRepositoryBuilder;
    3136
    32 
    3337PackageManager::PackageManager(Root* root, Volume* volume)
    3438    :
    3539    BPackageManager(volume->Location(), this, this),
    PackageManager::Warn(status_t error, const char* format, ...)  
    306310        message << BString().SetToFormat(": %s", strerror(error));
    307311
    308312    BNotification notification(B_ERROR_NOTIFICATION);
    309     notification.SetTitle("Package Daemon");
     313    notification.SetGroup(B_TRANSLATE("Package daemon"));
     314    notification.SetTitle(B_TRANSLATE("Warning"));
    310315    notification.SetContent(message);
     316    BBitmap icon(_GetIcon());
     317    if (icon.IsValid())
     318        notification.SetIcon(&icon);
    311319    notification.Send();
    312320}
    313321
    PackageManager::_InitGui()  
    404412    if (server == NULL || server->InitGUIContext() != B_OK)
    405413        throw BFatalErrorException("failed to initialize the GUI");
    406414}
     415
     416
     417BBitmap
     418PackageManager::_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}
  • src/servers/package/PackageManager.h

    diff --git a/src/servers/package/PackageManager.h b/src/servers/package/PackageManager.h
    index 123890d..e006c3a 100644
    a b  
    99#include <map>
    1010#include <set>
    1111
     12#include <Bitmap.h>
    1213#include <package/Context.h>
    1314#include <package/Job.h>
    1415
    private:  
    99100
    100101            void                _InitGui();
    101102
     103            BBitmap             _GetIcon();
     104
    102105private:
    103106            Root*               fRoot;
    104107            Volume*             fVolume;