2
0
mirror of https://gitlab.com/apparmor/apparmor synced 2025-08-30 13:58:22 +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:
Dominic Reynolds
2007-09-10 19:42:18 +00:00
parent b451a537c4
commit ddba73d87c
4 changed files with 105 additions and 2 deletions

View File

@@ -315,6 +315,20 @@
map<any,any> answers = UI_MultiProfileSelectionDialog( agent_data );
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") {
map<string,string> answers = $[ ];

View File

@@ -314,6 +314,20 @@
map<any,any> answers = UI_MultiProfileSelectionDialog( agent_data );
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") {
map<string,string> answers = $[ ];

View File

@@ -18,9 +18,9 @@
import "Popup";
import "AppArmorDialogs";
textdomain "yast2-apparmor";
map CMDS = $[ ];
CMDS["CMD_ALLOW"] = _("&Allow");
CMDS["CMD_DENY"] = _("&Deny");
@@ -602,3 +602,44 @@ define map<any,any> UI_MultiProfileSelectionDialog( map<any,any> agent_data ) {
UI::CloseDialog();
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;
}
}

View File

@@ -621,6 +621,7 @@ sub get_inactive_profile {
}
}
sub get_profile {
my $fqdbin = shift;
my $profile_data;
@@ -631,10 +632,12 @@ sub get_profile {
my @profile_list;
if (repo_is_enabled() && $repo_client) {
UI_BusyStart( gettext("Connecting to repository.....") );
my $res = $repo_client->send_request('FindProfiles',
$distro,
$fqdbin,
"");
UI_BusyStop();
if (did_result_succeed($res)) {
@profile_list = @{ $res->value };
@@ -651,10 +654,11 @@ sub get_profile {
}
if (@uids) {
UI_BusyStart( gettext("Connecting to repository.....") );
my $res =
$repo_client->send_request( 'LoginNamesFromUserIds',
[@uids] );
UI_BusyStop();
if (did_result_succeed($res)) {
my @usernames = @{ $res->value };
for my $uid (@uids) {
@@ -1142,6 +1146,31 @@ sub UI_GetFile ($) {
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 = (
CMD_ALLOW => "(A)llow",
CMD_DENY => "(D)eny",
@@ -2202,13 +2231,16 @@ sub read_log {
close(LOG);
}
sub get_repo_profiles_for_user {
my $username = shift;
my $distro = $cfg->{repository}{distro};
my $p_hash = {};
UI_BusyStart( gettext("Connecting to repository.....") );
my $res =
$repo_client->send_request('FindProfiles', $distro, "", $username);
UI_BusyStop();
if (did_result_succeed($res)) {
for my $p ( @$res ) {
$p_hash->{$p->{name}->value()} = $p->{profile}->value();
@@ -2232,8 +2264,10 @@ sub check_repo_for_newer {
my $p;
if ($repo_client) {
UI_BusyStart( gettext("Connecting to repository.....") );
my $res =
$repo_client->send_request('FindProfiles', $distro, $profile, $user);
UI_BusyStop();
if (did_result_succeed($res)) {
my @profiles;
my @profile_list = @{$res->value};