Aut::UI::Wx - A wxPerl User Interface for the Aut framework.


Aut-UI-Wx documentation Contained in the Aut-UI-Wx distribution.

Index


Code Index:

NAME

Top

Aut::UI::Wx - A wxPerl User Interface for the Aut framework.

ABSTRACT

Top

This module provides a wxPerl User Interface for the authorization framework (see Aut::UI::Console for an interface description).

DESCRIPTION

Top

This User Interface has the same interface as Aut::UI::Console. Please refere to this interface for more information.

Interface

The interface extends the minimal Aut::UI::Console interface.

Functions

new([parent]) --> Aut::UI::Wx

The new function of this interface accepts a 'parent' window id. Which is normal for wxWidgets.

message_ok(text, [title], [parent]) --> void

This function accepts beneath the standard text also a title and a parent. It will display a messagebox with an OK buttonthat is centered on the parent.

ask_pass(text,[title],[parent]) --> string

This function accepts beneath the standard text also a title and a parent. It will display a dialog asking for a password with a Cancel and an OK button.

Returns 'undef' in case of a Cancel, or if an empty password has been given.

login(aut:Aut, [title], [parent]) --> Aut::Ticket

See Aut::UI::Console. This function displays a dialog with a Cancel and a OK button. Cancel will yield an invalid ticket.

logout(aut:Aut, ticket:Aut::Ticket) --> void

Currently only invalidates the ticket.

change_pass(aut:Aut, ticket:Aut::Ticket, [title], [parent]) --> void

Changes the password, see Aut::UI::Console.

admin(aut::Aut, ticket:Aut::Ticket, [title], [parent]) --> void

Administers the accounts, see Aut::UI::Console.

SEE ALSO

Top

Aut, Aut::Ticket, Aut::Backend::Conf, Aut::UI::Console.

AUTHOR

Top

Hans Oesterholt-Dijkema <oesterhol@cpan.org>

COPYRIGHT AND LICENSE

Top


Aut-UI-Wx documentation Contained in the Aut-UI-Wx distribution.

package Aut::UI::Wx;

use strict;
use Locale::Framework;
use Aut::UI::wxGUI;
use Aut;
use Aut::Ticket;
use Wx qw(:everything);

our $VERSION='0.02';

#####################################################
# Instantiation/Initialization
#####################################################

sub new {
  my $class=shift;
  my $parent=shift;
  my $self;

  if (defined $parent) {
    $self->{"parent"}=$parent;
  }
  else {
    $self->{"parent"}=undef;
  }

  $self->{"levels"}=undef;
  $self->{"admin"}=undef;

  bless $self,$class;
return $self;
}

sub initialize {
  my $self=shift;
  my $levels=shift;
  my $adminlevel=shift;

  $self->{"levels"}=$levels;
  $self->{"admin"}=$adminlevel;
}

sub levels {
  my $self=shift;
return @{$self->{"levels"}};
}

#####################################################
# Messages
#####################################################

sub message_ok {
  my $self=shift;
  my $text=shift;
  my $title=shift;
  my $parent=shift;

  if (not defined $title) { $title=_T("Alert"); }
  if (not defined $parent) { $parent=$self->{"parent"}; }
  
  #my $dlg=new __Aut__Msg($parent,-1,$title);
  #$dlg->set_label($text);
  #$dlg->ShowModal();
  #$dlg->Destroy();
  Wx::MessageBox( $text, $title, wxOK|wxCENTRE, $parent );
}

sub message {
  
}

#####################################################
# Password/account related
#####################################################

sub ask_pass {
  my $self=shift;
  my $aut=shift;
  my $text=shift;
  my $title=shift;
  my $parent=shift;
  my $pass;

  if (not defined $title) { $title=_T("Give password"); }
  if (not defined $parent) { $parent=$self->{"parent"}; }

  my $dlg=new __Aut__Entry($parent,-1,$title);

  $dlg->set_label($text);
  $dlg->SetTitle($title);
  if ($dlg->ShowModal()==wxID_OK) {
    $pass=$dlg->get_value();
    if ($pass eq "") {
      $pass=undef;
    }
  }
  else {
    $pass=undef;
  }

  $dlg->Destroy();

return $pass;
}

sub login {
  my $self=shift;
  my $aut=shift;
  my $title=shift;
  my $parent=shift;

  if (not defined $title) { $title=_T("Login"); }
  if (not defined $parent) { $parent=$self->{"parent"}; }

  my $dlg=new __Aut__dlgLogin($parent,-1,$title);
  $dlg->set_aut($aut);
  $dlg->set_ui($self);


  $dlg->ShowModal();

  my $ticket=$dlg->ticket();

  $dlg->Destroy();

return $ticket;
}

sub logout {
  my $self=shift;
  my $aut=shift;
  my $ticket=shift;
  $ticket->invalidate();
return 1;
}

sub change_pass {
  my $self=shift;
  my $aut=shift;
  my $ticket=shift;
  my $title=shift;
  my $parent=shift;

  if (not defined $title) { $title=_T("Change Password"); }
  if (not defined $parent) { $parent=$self->{"parent"}; }

  my $dlg=new __Aut__ChangePass($parent,-1,$title);
  $dlg->set_aut($aut);
  $dlg->set_ui($self);
  $dlg->set_account($ticket->account());
  $dlg->set_ticket($ticket);

  $dlg->ShowModal();

  $dlg->Destroy();
}

#####################################################
# Administration
#####################################################

sub admin {
  my $self=shift;
  my $aut=shift;
  my $ticket=shift;
  my $title=shift;
  my $parent=shift;

  if (not defined $title) { $title=_T("Account Administration"); }
  if (not defined $parent) { $parent=$self->{"parent"}; }

  my $dlg=new __Aut__AdminAccounts($parent,-1,$title);
  $dlg->set_aut($aut);
  $dlg->set_ui($self);
  $dlg->set_ticket($ticket);

  if ($dlg->initialize()) {
    $dlg->ShowModal();
  }

  $dlg->Destroy();
}

1;
__END__