summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rwxr-xr-xmdkapplet-restricted-helper11
-rw-r--r--mdkonline.pm17
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;