summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJoão Victor Duarte Martins <jvictor@mandriva.com>2010-05-13 18:51:28 +0000
committerJoão Victor Duarte Martins <jvictor@mandriva.com>2010-05-13 18:51:28 +0000
commit6cfd95a49b0c0df8b334f43b3e6e3df9d1806778 (patch)
treeb4604dd13c7c76281c0a17b580b78687be26419b
parentd1d202c7a9a264f4025c60d993f383c7a0ebbe89 (diff)
downloadmgaonline-6cfd95a49b0c0df8b334f43b3e6e3df9d1806778.tar
mgaonline-6cfd95a49b0c0df8b334f43b3e6e3df9d1806778.tar.gz
mgaonline-6cfd95a49b0c0df8b334f43b3e6e3df9d1806778.tar.bz2
mgaonline-6cfd95a49b0c0df8b334f43b3e6e3df9d1806778.tar.xz
mgaonline-6cfd95a49b0c0df8b334f43b3e6e3df9d1806778.zip
* mdkonline.pm (get_my_mdv_profile): Moved from authenticate_callback
for reusability. * mdkapplet-add-media-helper (authenticate_callback): renamed for readability.
-rwxr-xr-xmdkapplet-add-media-helper18
-rw-r--r--mdkonline.pm8
2 files changed, 15 insertions, 11 deletions
diff --git a/mdkapplet-add-media-helper b/mdkapplet-add-media-helper
index e0b04847..af710799 100755
--- a/mdkapplet-add-media-helper
+++ b/mdkapplet-add-media-helper
@@ -127,7 +127,7 @@ sub run_authentication_dialog {
"additional package medium");
mdkapplet_gui::run_ask_credentials_dialog($title,
$description,
- \&add_restricted_medium);
+ \&authenticate_callback);
ugtk2::exit(0);
}
@@ -155,22 +155,18 @@ sub run_no_rights_dialog() {
mdkapplet_gui::fill_n_run_portable_dialog($w, \@widgets);
}
-sub add_restricted_medium {
+sub authenticate_callback {
my ($email, $passwd) = @_;
my $product = $product{$up_product};
- my $my_profile = mdkonline::xml2perl(
- mdkonline::get_from("https://my.mandriva.com/rest/authenticate",
- [ 'username', $email,
- 'password', $passwd,
- 'return', 'userdata' ]
- ));
- if ($my_profile->{code} != 0) {
+ my $profile = mdkonline::get_my_mdv_profile();
+
+ if ($profile->{code} != 0) {
my $in = interactive->vnew;
$in->ask_warn(N("Error"),
- N("An error occurred") . "\n" . $my_profile->{message});
+ N("An error occurred") . "\n" . $profile->{message});
goto &run_authentication_dialog;
}
- elsif (!$product->{has_rights}->($my_profile)) {
+ elsif (!$product->{has_rights}->($profile)) {
run_no_rights_dialog();
}
else {
diff --git a/mdkonline.pm b/mdkonline.pm
index 6c67b54c..02399a66 100644
--- a/mdkonline.pm
+++ b/mdkonline.pm
@@ -50,6 +50,7 @@ our @EXPORT = qw(find_current_distro
$config_file
$product_id
$root);
+our @EXPORT_OK = qw(get_my_mdv_profile);
our (%config, $product_id, $root);
our $version = 1;
@@ -211,6 +212,13 @@ sub get_from {
$response;
}
+sub get_my_mdv_profile {
+ my ($email, $password) = @_;
+ xml2perl(mdkonline::get_from('https://my.mandriva.com/rest/authenticate',
+ [ 'username', $email, 'password', $password,
+ 'return', 'userdata' ]));
+}
+
# callers need to require XML::Simple
sub xml2perl {
my ($res) = @_;