Add the access string to the app access request dialog.

This way the user can see what operation the application tries to do.
This commit is contained in:
Michael Lotz
2013-03-05 11:04:48 -05:00
committed by Ryan Leavengood
parent cbdd5aff17
commit a59169de6f
4 changed files with 26 additions and 13 deletions
@@ -31,7 +31,8 @@ static const uint32 kMessageAlways = 'btaa';
class AppAccessRequestView : public BView { class AppAccessRequestView : public BView {
public: public:
AppAccessRequestView(const char* keyringName, const char* signature, 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) BView("AppAccessRequestView", B_WILL_DRAW)
{ {
@@ -52,10 +53,18 @@ public:
return; return;
BString details; BString details;
details << "The application:\n\n" details << "The application:\n"
<< signature << " (" << path << ")\n\n" << signature << " (" << path << ")\n\n";
<< "requests access to keyring:\n\n"
<< keyringName << "\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) if (appIsNew)
details << "This application hasn't been granted access before."; details << "This application hasn't been granted access before.";
@@ -120,7 +129,8 @@ private:
AppAccessRequestWindow::AppAccessRequestWindow(const char* keyringName, 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", BWindow(BRect(50, 50, 269, 302), "Application Keyring Access",
B_TITLED_WINDOW, B_NOT_RESIZABLE | B_ASYNCHRONOUS_CONTROLS B_TITLED_WINDOW, B_NOT_RESIZABLE | B_ASYNCHRONOUS_CONTROLS
@@ -140,7 +150,7 @@ AppAccessRequestWindow::AppAccessRequestWindow(const char* keyringName,
SetLayout(layout); SetLayout(layout);
fRequestView = new(std::nothrow) AppAccessRequestView(keyringName, fRequestView = new(std::nothrow) AppAccessRequestView(keyringName,
signature, path, appIsNew, appWasUpdated); signature, path, accessString, appIsNew, appWasUpdated);
if (fRequestView == NULL) if (fRequestView == NULL)
return; return;
@@ -18,7 +18,8 @@ public:
AppAccessRequestWindow( AppAccessRequestWindow(
const char* keyringName, const char* keyringName,
const char* signature, const char* signature,
const char* path, bool appIsNew, const char* path,
const char* accessString, bool appIsNew,
bool appWasUpdated); bool appWasUpdated);
virtual ~AppAccessRequestWindow(); virtual ~AppAccessRequestWindow();
+5 -4
View File
@@ -635,9 +635,10 @@ KeyStoreServer::_ValidateAppAccess(Keyring& keyring, const app_info& appInfo,
if ((accessFlags & appFlags) == accessFlags) if ((accessFlags & appFlags) == accessFlags)
return B_OK; return B_OK;
const char* accessString = _AccessStringFor(accessFlags);
bool allowAlways = false; bool allowAlways = false;
result = _RequestAppAccess(keyring.Name(), appInfo.signature, path.Path(), result = _RequestAppAccess(keyring.Name(), appInfo.signature, path.Path(),
appIsNew, appWasUpdated, accessFlags, allowAlways); accessString, appIsNew, appWasUpdated, accessFlags, allowAlways);
if (result != B_OK || !allowAlways) if (result != B_OK || !allowAlways)
return result; return result;
@@ -656,12 +657,12 @@ KeyStoreServer::_ValidateAppAccess(Keyring& keyring, const app_info& appInfo,
status_t status_t
KeyStoreServer::_RequestAppAccess(const BString& keyringName, KeyStoreServer::_RequestAppAccess(const BString& keyringName,
const char* signature, const char* path, bool appIsNew, bool appWasUpdated, const char* signature, const char* path, const char* accessString,
uint32 accessFlags, bool& allowAlways) bool appIsNew, bool appWasUpdated, uint32 accessFlags, bool& allowAlways)
{ {
AppAccessRequestWindow* requestWindow AppAccessRequestWindow* requestWindow
= new(std::nothrow) AppAccessRequestWindow(keyringName, signature, path, = new(std::nothrow) AppAccessRequestWindow(keyringName, signature, path,
appIsNew, appWasUpdated); accessString, appIsNew, appWasUpdated);
if (requestWindow == NULL) if (requestWindow == NULL)
return B_NO_MEMORY; return B_NO_MEMORY;
+2 -1
View File
@@ -40,7 +40,8 @@ private:
status_t _RequestAppAccess( status_t _RequestAppAccess(
const BString& keyringName, const BString& keyringName,
const char* signature, const char* signature,
const char* path, bool appIsNew, const char* path,
const char* accessString, bool appIsNew,
bool appWasUpdated, uint32 accessFlags, bool appWasUpdated, uint32 accessFlags,
bool& allowAlways); bool& allowAlways);