diff options
author | Thierry Vignaud <tv@mandriva.org> | 2009-07-28 12:33:38 +0000 |
---|---|---|
committer | Thierry Vignaud <tv@mandriva.org> | 2009-07-28 12:33:38 +0000 |
commit | 8585f58cc94e9cd73ef28c9a2bcbb8106353358f (patch) | |
tree | b3ba4d3b80c9a62de663c9974eb2360f9b2eb93b | |
parent | 35db8adc23041e6aaf4c2b41849167e0749f7f97 (diff) | |
download | mgaonline-8585f58cc94e9cd73ef28c9a2bcbb8106353358f.tar mgaonline-8585f58cc94e9cd73ef28c9a2bcbb8106353358f.tar.gz mgaonline-8585f58cc94e9cd73ef28c9a2bcbb8106353358f.tar.bz2 mgaonline-8585f58cc94e9cd73ef28c9a2bcbb8106353358f.tar.xz mgaonline-8585f58cc94e9cd73ef28c9a2bcbb8106353358f.zip |
(xml2perl) factorize code (needed for next commit)
-rwxr-xr-x | mdkapplet-restricted-helper | 11 | ||||
-rw-r--r-- | mdkonline.pm | 17 |
2 files changed, 18 insertions, 10 deletions
diff --git a/mdkapplet-restricted-helper b/mdkapplet-restricted-helper index f2737061..55e55265 100755 --- a/mdkapplet-restricted-helper +++ b/mdkapplet-restricted-helper @@ -116,17 +116,10 @@ my $error; sub add_restricted_medium { my ($email, $password) = @_; - my $res = get_from("https://my.mandriva.com/rest/authenticate", + my $res = get_from("https://my.mandriva.com/rest/authenticate2", [ 'username', $email, 'password', $password, 'return', 'userdata' ]); - my $ref = eval { XML::Simple->new->XMLin($res->{_content}) }; - if (my $err = $@) { - warn ">> XML error: $err\n"; - $ref = { - code => 1, - message => $err, - }; - } + my $ref = xml2perl($res); if ($ref->{code} != 0) { my $in = interactive->vnew; diff --git a/mdkonline.pm b/mdkonline.pm index 361ad0e0..48b9fb4d 100644 --- a/mdkonline.pm +++ b/mdkonline.pm @@ -30,7 +30,7 @@ use common; use ugtk2; our @ISA = qw(Exporter); -our @EXPORT = qw(fork_exec get_banner get_stale_upgrade_filename); +our @EXPORT = qw(fork_exec get_banner get_stale_upgrade_filename xml2perl); our $version = 2.67; @@ -80,4 +80,19 @@ sub is_running { $found; } +# callers need to require XML::Simple +sub xml2perl { + my ($res) = @_; + my $ref = eval { XML::Simple->new->XMLin($res->{_content}) }; + if (my $err = $@) { + warn ">> XML error: $err\n"; + $ref = { + code => 1, + message => $err, + }; + } + $ref; +} + + 1; |