]>
git.proxmox.com Git - pve-installer.git/blob - Proxmox/UI/StdIO.pm
1 package Proxmox
::UI
::StdIO
;
6 use JSON
qw(from_json to_json);
8 use base
qw(Proxmox::UI::Base);
12 my sub send_msg
: prototype($$) {
13 my ($type, %values) = @_;
15 my $json = to_json
({ type
=> $type, %values }, { utf8
=> 1, canonical
=> 1 });
16 print STDOUT
"$json\n";
19 my sub recv_msg
: prototype() {
20 my $response = <STDIN
> // ''; # FIXME: error handling?
23 return eval { from_json
($response, { utf8
=> 1 }) };
33 my ($self, $msg) = @_;
35 &send_msg
('message', message
=> $msg);
39 my ($self, $msg) = @_;
41 log_error
("error: $msg");
42 &send_msg
('error', message
=> $msg);
46 my ($self, $success, $msg) = @_;
48 my $state = $success ?
'ok' : 'err';
49 log_info
("finished: $state, $msg");
50 &send_msg
('finished', state => $state, message
=> $msg);
54 my ($self, $query) = @_;
56 &send_msg
('prompt', query
=> $query);
57 my $response = &recv_msg
();
59 if (defined($response) && $response->{type
} eq 'prompt-answer') {
60 return lc($response->{answer
}) eq 'ok';
65 my ($raw_html, $html_dir) = @_;
67 log_error
("display_html() not available for stdio backend!");
71 my ($self, $ratio, $text) = @_;
73 $text = '' if !defined($text);
75 &send_msg
('progress', ratio
=> $ratio, text
=> $text);
81 # nothing to do for now?