From a59169de6f5fd92ba06d5d3836a4223b22cb8b6e Mon Sep 17 00:00:00 2001 From: Michael Lotz Date: Sun, 24 Jun 2012 16:06:41 +0200 Subject: [PATCH] Add the access string to the app access request dialog. This way the user can see what operation the application tries to do. --- .../keystore/AppAccessRequestWindow.cpp | 24 +++++++++++++------ src/servers/keystore/AppAccessRequestWindow.h | 3 ++- src/servers/keystore/KeyStoreServer.cpp | 9 +++---- src/servers/keystore/KeyStoreServer.h | 3 ++- 4 files changed, 26 insertions(+), 13 deletions(-) diff --git a/src/servers/keystore/AppAccessRequestWindow.cpp b/src/servers/keystore/AppAccessRequestWindow.cpp index d4fb25f7fa..bb63438373 100644 --- a/src/servers/keystore/AppAccessRequestWindow.cpp +++ b/src/servers/keystore/AppAccessRequestWindow.cpp @@ -31,7 +31,8 @@ static const uint32 kMessageAlways = 'btaa'; class AppAccessRequestView : public BView { public: AppAccessRequestView(const char* keyringName, const char* signature, - const char* path, bool appIsNew, bool appWasUpdated) + const char* path, const char* accessString, bool appIsNew, + bool appWasUpdated) : BView("AppAccessRequestView", B_WILL_DRAW) { @@ -52,10 +53,18 @@ public: return; BString details; - details << "The application:\n\n" - << signature << " (" << path << ")\n\n" - << "requests access to keyring:\n\n" - << keyringName << "\n\n"; + details << "The application:\n" + << signature << " (" << path << ")\n\n"; + + if (keyringName != NULL) { + details << "requests access to keyring:\n" + << keyringName << "\n\n"; + } + + if (accessString != NULL) { + details << "to perform the following action:\n" + << accessString << "\n\n"; + } if (appIsNew) details << "This application hasn't been granted access before."; @@ -120,7 +129,8 @@ private: AppAccessRequestWindow::AppAccessRequestWindow(const char* keyringName, - const char* signature, const char* path, bool appIsNew, bool appWasUpdated) + const char* signature, const char* path, const char* accessString, + bool appIsNew, bool appWasUpdated) : BWindow(BRect(50, 50, 269, 302), "Application Keyring Access", B_TITLED_WINDOW, B_NOT_RESIZABLE | B_ASYNCHRONOUS_CONTROLS @@ -140,7 +150,7 @@ AppAccessRequestWindow::AppAccessRequestWindow(const char* keyringName, SetLayout(layout); fRequestView = new(std::nothrow) AppAccessRequestView(keyringName, - signature, path, appIsNew, appWasUpdated); + signature, path, accessString, appIsNew, appWasUpdated); if (fRequestView == NULL) return; diff --git a/src/servers/keystore/AppAccessRequestWindow.h b/src/servers/keystore/AppAccessRequestWindow.h index 2dfbd875e8..e8fbee8a5b 100644 --- a/src/servers/keystore/AppAccessRequestWindow.h +++ b/src/servers/keystore/AppAccessRequestWindow.h @@ -18,7 +18,8 @@ public: AppAccessRequestWindow( const char* keyringName, const char* signature, - const char* path, bool appIsNew, + const char* path, + const char* accessString, bool appIsNew, bool appWasUpdated); virtual ~AppAccessRequestWindow(); diff --git a/src/servers/keystore/KeyStoreServer.cpp b/src/servers/keystore/KeyStoreServer.cpp index 2717012279..19fe75435e 100644 --- a/src/servers/keystore/KeyStoreServer.cpp +++ b/src/servers/keystore/KeyStoreServer.cpp @@ -635,9 +635,10 @@ KeyStoreServer::_ValidateAppAccess(Keyring& keyring, const app_info& appInfo, if ((accessFlags & appFlags) == accessFlags) return B_OK; + const char* accessString = _AccessStringFor(accessFlags); bool allowAlways = false; result = _RequestAppAccess(keyring.Name(), appInfo.signature, path.Path(), - appIsNew, appWasUpdated, accessFlags, allowAlways); + accessString, appIsNew, appWasUpdated, accessFlags, allowAlways); if (result != B_OK || !allowAlways) return result; @@ -656,12 +657,12 @@ KeyStoreServer::_ValidateAppAccess(Keyring& keyring, const app_info& appInfo, status_t KeyStoreServer::_RequestAppAccess(const BString& keyringName, - const char* signature, const char* path, bool appIsNew, bool appWasUpdated, - uint32 accessFlags, bool& allowAlways) + const char* signature, const char* path, const char* accessString, + bool appIsNew, bool appWasUpdated, uint32 accessFlags, bool& allowAlways) { AppAccessRequestWindow* requestWindow = new(std::nothrow) AppAccessRequestWindow(keyringName, signature, path, - appIsNew, appWasUpdated); + accessString, appIsNew, appWasUpdated); if (requestWindow == NULL) return B_NO_MEMORY; diff --git a/src/servers/keystore/KeyStoreServer.h b/src/servers/keystore/KeyStoreServer.h index 8af20ad7bf..aa25f82ca8 100644 --- a/src/servers/keystore/KeyStoreServer.h +++ b/src/servers/keystore/KeyStoreServer.h @@ -40,7 +40,8 @@ private: status_t _RequestAppAccess( const BString& keyringName, const char* signature, - const char* path, bool appIsNew, + const char* path, + const char* accessString, bool appIsNew, bool appWasUpdated, uint32 accessFlags, bool& allowAlways);