From ddba73d87c1ecede721bbdedf23dfb0c623267c6 Mon Sep 17 00:00:00 2001 From: Dominic Reynolds Date: Mon, 10 Sep 2007 19:42:18 +0000 Subject: [PATCH] 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. --- management/yastui/src/clients/GenProf.ycp | 14 ++++++ management/yastui/src/clients/LogProf.ycp | 14 ++++++ .../include/subdomain/apparmor_ycp_utils.ycp | 43 ++++++++++++++++++- utils/SubDomain.pm | 36 +++++++++++++++- 4 files changed, 105 insertions(+), 2 deletions(-) diff --git a/management/yastui/src/clients/GenProf.ycp b/management/yastui/src/clients/GenProf.ycp index d5a321b51..9e3062b5e 100644 --- a/management/yastui/src/clients/GenProf.ycp +++ b/management/yastui/src/clients/GenProf.ycp @@ -315,6 +315,20 @@ map answers = UI_MultiProfileSelectionDialog( agent_data ); SCR::Write(.genprof, answers); + } else if (type == "dialog-busy-start") { + + map answers = $[ ]; + UI_BusyFeedbackStart( agent_data ); + answers["answer"] = "okay"; + SCR::Write(.genprof, answers); + + } else if (type == "dialog-busy-stop") { + + map answers = $[ ]; + UI_BusyFeedbackStop( ); + answers["answer"] = "okay"; + SCR::Write(.genprof, answers); + } else if (type == "long-dialog-message") { map answers = $[ ]; diff --git a/management/yastui/src/clients/LogProf.ycp b/management/yastui/src/clients/LogProf.ycp index 4c26ad427..d3304abc2 100644 --- a/management/yastui/src/clients/LogProf.ycp +++ b/management/yastui/src/clients/LogProf.ycp @@ -314,6 +314,20 @@ map answers = UI_MultiProfileSelectionDialog( agent_data ); SCR::Write(.logprof, answers); + } else if (type == "dialog-busy-start") { + + map answers = $[ ]; + UI_BusyFeedbackStart( agent_data ); + answers["answer"] = "okay"; + SCR::Write(.logprof, answers); + + } else if (type == "dialog-busy-stop") { + + map answers = $[ ]; + UI_BusyFeedbackStop( ); + answers["answer"] = "okay"; + SCR::Write(.logprof, answers); + } else if (type == "long-dialog-message") { map answers = $[ ]; diff --git a/management/yastui/src/include/subdomain/apparmor_ycp_utils.ycp b/management/yastui/src/include/subdomain/apparmor_ycp_utils.ycp index 7dd4c61d6..8b47d625d 100644 --- a/management/yastui/src/include/subdomain/apparmor_ycp_utils.ycp +++ b/management/yastui/src/include/subdomain/apparmor_ycp_utils.ycp @@ -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 UI_MultiProfileSelectionDialog( map 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 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; + } +} diff --git a/utils/SubDomain.pm b/utils/SubDomain.pm index 99bee52ee..aa957d03f 100755 --- a/utils/SubDomain.pm +++ b/utils/SubDomain.pm @@ -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};