mirror of
https://gitlab.com/apparmor/apparmor
synced 2025-08-31 06:16:03 +00:00
Very basic user feedback when connections are made to a remote
repository. For genprof/logprof just report "Connecting to the repository". For yast display a dialog.
This commit is contained in:
@@ -315,6 +315,20 @@
|
|||||||
map<any,any> answers = UI_MultiProfileSelectionDialog( agent_data );
|
map<any,any> answers = UI_MultiProfileSelectionDialog( agent_data );
|
||||||
SCR::Write(.genprof, answers);
|
SCR::Write(.genprof, answers);
|
||||||
|
|
||||||
|
} else if (type == "dialog-busy-start") {
|
||||||
|
|
||||||
|
map<string,string> answers = $[ ];
|
||||||
|
UI_BusyFeedbackStart( agent_data );
|
||||||
|
answers["answer"] = "okay";
|
||||||
|
SCR::Write(.genprof, answers);
|
||||||
|
|
||||||
|
} else if (type == "dialog-busy-stop") {
|
||||||
|
|
||||||
|
map<string,string> answers = $[ ];
|
||||||
|
UI_BusyFeedbackStop( );
|
||||||
|
answers["answer"] = "okay";
|
||||||
|
SCR::Write(.genprof, answers);
|
||||||
|
|
||||||
} else if (type == "long-dialog-message") {
|
} else if (type == "long-dialog-message") {
|
||||||
|
|
||||||
map<string,string> answers = $[ ];
|
map<string,string> answers = $[ ];
|
||||||
|
@@ -314,6 +314,20 @@
|
|||||||
map<any,any> answers = UI_MultiProfileSelectionDialog( agent_data );
|
map<any,any> answers = UI_MultiProfileSelectionDialog( agent_data );
|
||||||
SCR::Write(.logprof, answers);
|
SCR::Write(.logprof, answers);
|
||||||
|
|
||||||
|
} else if (type == "dialog-busy-start") {
|
||||||
|
|
||||||
|
map<string,string> answers = $[ ];
|
||||||
|
UI_BusyFeedbackStart( agent_data );
|
||||||
|
answers["answer"] = "okay";
|
||||||
|
SCR::Write(.logprof, answers);
|
||||||
|
|
||||||
|
} else if (type == "dialog-busy-stop") {
|
||||||
|
|
||||||
|
map<string,string> answers = $[ ];
|
||||||
|
UI_BusyFeedbackStop( );
|
||||||
|
answers["answer"] = "okay";
|
||||||
|
SCR::Write(.logprof, answers);
|
||||||
|
|
||||||
} else if (type == "long-dialog-message") {
|
} else if (type == "long-dialog-message") {
|
||||||
|
|
||||||
map<string,string> answers = $[ ];
|
map<string,string> answers = $[ ];
|
||||||
|
@@ -18,9 +18,9 @@
|
|||||||
|
|
||||||
|
|
||||||
import "Popup";
|
import "Popup";
|
||||||
|
import "AppArmorDialogs";
|
||||||
textdomain "yast2-apparmor";
|
textdomain "yast2-apparmor";
|
||||||
|
|
||||||
|
|
||||||
map CMDS = $[ ];
|
map CMDS = $[ ];
|
||||||
CMDS["CMD_ALLOW"] = _("&Allow");
|
CMDS["CMD_ALLOW"] = _("&Allow");
|
||||||
CMDS["CMD_DENY"] = _("&Deny");
|
CMDS["CMD_DENY"] = _("&Deny");
|
||||||
@@ -602,3 +602,44 @@ define map<any,any> UI_MultiProfileSelectionDialog( map<any,any> agent_data ) {
|
|||||||
UI::CloseDialog();
|
UI::CloseDialog();
|
||||||
return results;
|
return results;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** Form_BusyFeedbackDialog
|
||||||
|
*
|
||||||
|
* @param agent_data - map - data from backend
|
||||||
|
* [ title - string - explanation of the forms use ]
|
||||||
|
*
|
||||||
|
* @return results - map
|
||||||
|
* [ STATUS - string - ok/cancel ]
|
||||||
|
*
|
||||||
|
**/
|
||||||
|
|
||||||
|
define term Form_BusyFeedbackDialog( string message ) {
|
||||||
|
//`MinSize( 10, 4, `Image(`opt(`animated), movie, "animation" ),
|
||||||
|
//`Image(`opt(`animated), movie, "animation" ),
|
||||||
|
string movie =
|
||||||
|
"/usr/share/YaST2/theme/current/animations/ticks-endless.gif";
|
||||||
|
term busy_dialog =
|
||||||
|
`HBox(
|
||||||
|
//`MinSize( 10, 4, `Image(`opt(`animated), movie, "animation" ) ),
|
||||||
|
`Image(`opt(`animated), movie, "animation" ),
|
||||||
|
`Label( message )
|
||||||
|
);
|
||||||
|
return busy_dialog;
|
||||||
|
}
|
||||||
|
|
||||||
|
define void UI_BusyFeedbackStart( map<any,any> agent_data ) {
|
||||||
|
string message = agent_data["message"]:"MISSING MESSAGE";
|
||||||
|
if ( AppArmorDialogs::busy_dialog != nil ) {
|
||||||
|
UI::CloseDialog();
|
||||||
|
}
|
||||||
|
AppArmorDialogs::busy_dialog = Form_BusyFeedbackDialog( message );
|
||||||
|
UI::OpenDialog( AppArmorDialogs::busy_dialog);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
define void UI_BusyFeedbackStop( ) {
|
||||||
|
if ( AppArmorDialogs::busy_dialog != nil ) {
|
||||||
|
UI::CloseDialog();
|
||||||
|
AppArmorDialogs::busy_dialog = nil;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@@ -621,6 +621,7 @@ sub get_inactive_profile {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
sub get_profile {
|
sub get_profile {
|
||||||
my $fqdbin = shift;
|
my $fqdbin = shift;
|
||||||
my $profile_data;
|
my $profile_data;
|
||||||
@@ -631,10 +632,12 @@ sub get_profile {
|
|||||||
my @profile_list;
|
my @profile_list;
|
||||||
|
|
||||||
if (repo_is_enabled() && $repo_client) {
|
if (repo_is_enabled() && $repo_client) {
|
||||||
|
UI_BusyStart( gettext("Connecting to repository.....") );
|
||||||
my $res = $repo_client->send_request('FindProfiles',
|
my $res = $repo_client->send_request('FindProfiles',
|
||||||
$distro,
|
$distro,
|
||||||
$fqdbin,
|
$fqdbin,
|
||||||
"");
|
"");
|
||||||
|
UI_BusyStop();
|
||||||
if (did_result_succeed($res)) {
|
if (did_result_succeed($res)) {
|
||||||
@profile_list = @{ $res->value };
|
@profile_list = @{ $res->value };
|
||||||
|
|
||||||
@@ -651,10 +654,11 @@ sub get_profile {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (@uids) {
|
if (@uids) {
|
||||||
|
UI_BusyStart( gettext("Connecting to repository.....") );
|
||||||
my $res =
|
my $res =
|
||||||
$repo_client->send_request( 'LoginNamesFromUserIds',
|
$repo_client->send_request( 'LoginNamesFromUserIds',
|
||||||
[@uids] );
|
[@uids] );
|
||||||
|
UI_BusyStop();
|
||||||
if (did_result_succeed($res)) {
|
if (did_result_succeed($res)) {
|
||||||
my @usernames = @{ $res->value };
|
my @usernames = @{ $res->value };
|
||||||
for my $uid (@uids) {
|
for my $uid (@uids) {
|
||||||
@@ -1142,6 +1146,31 @@ sub UI_GetFile ($) {
|
|||||||
return $filename;
|
return $filename;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
sub UI_BusyStart ($) {
|
||||||
|
my $message = shift;
|
||||||
|
$DEBUGGING && debug "UI_BusyStart: $UI_Mode";
|
||||||
|
|
||||||
|
if ($UI_Mode eq "text") {
|
||||||
|
UI_Info( $message );
|
||||||
|
} else {
|
||||||
|
SendDataToYast({
|
||||||
|
type => "dialog-busy-start",
|
||||||
|
message => $message,
|
||||||
|
});
|
||||||
|
my ($ypath, $yarg) = GetDataFromYast();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
sub UI_BusyStop {
|
||||||
|
$DEBUGGING && debug "UI_BusyStop: $UI_Mode";
|
||||||
|
|
||||||
|
if ($UI_Mode ne "text") {
|
||||||
|
SendDataToYast({ type => "dialog-busy-stop" });
|
||||||
|
my ($ypath, $yarg) = GetDataFromYast();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
my %CMDS = (
|
my %CMDS = (
|
||||||
CMD_ALLOW => "(A)llow",
|
CMD_ALLOW => "(A)llow",
|
||||||
CMD_DENY => "(D)eny",
|
CMD_DENY => "(D)eny",
|
||||||
@@ -2202,13 +2231,16 @@ sub read_log {
|
|||||||
close(LOG);
|
close(LOG);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
sub get_repo_profiles_for_user {
|
sub get_repo_profiles_for_user {
|
||||||
my $username = shift;
|
my $username = shift;
|
||||||
|
|
||||||
my $distro = $cfg->{repository}{distro};
|
my $distro = $cfg->{repository}{distro};
|
||||||
my $p_hash = {};
|
my $p_hash = {};
|
||||||
|
UI_BusyStart( gettext("Connecting to repository.....") );
|
||||||
my $res =
|
my $res =
|
||||||
$repo_client->send_request('FindProfiles', $distro, "", $username);
|
$repo_client->send_request('FindProfiles', $distro, "", $username);
|
||||||
|
UI_BusyStop();
|
||||||
if (did_result_succeed($res)) {
|
if (did_result_succeed($res)) {
|
||||||
for my $p ( @$res ) {
|
for my $p ( @$res ) {
|
||||||
$p_hash->{$p->{name}->value()} = $p->{profile}->value();
|
$p_hash->{$p->{name}->value()} = $p->{profile}->value();
|
||||||
@@ -2232,8 +2264,10 @@ sub check_repo_for_newer {
|
|||||||
|
|
||||||
my $p;
|
my $p;
|
||||||
if ($repo_client) {
|
if ($repo_client) {
|
||||||
|
UI_BusyStart( gettext("Connecting to repository.....") );
|
||||||
my $res =
|
my $res =
|
||||||
$repo_client->send_request('FindProfiles', $distro, $profile, $user);
|
$repo_client->send_request('FindProfiles', $distro, $profile, $user);
|
||||||
|
UI_BusyStop();
|
||||||
if (did_result_succeed($res)) {
|
if (did_result_succeed($res)) {
|
||||||
my @profiles;
|
my @profiles;
|
||||||
my @profile_list = @{$res->value};
|
my @profile_list = @{$res->value};
|
||||||
|
Reference in New Issue
Block a user