1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126
| #!/usr/bin/perl
use Tk;
use strict;
use warnings;
use Net::POP3;
use Tk::NoteBook;
my $fenetre = new MainWindow( -title => "Authentification", );
# Taille minimale de la fenêtre
$fenetre->minsize( 300, 100 );
my $host = $fenetre->Entry( -text => "host", )->pack();
$host->focus;
my $login = $fenetre->Entry( -text => "user\@sample.org", )->pack();
my $pass = $fenetre->Entry(
-text => "password",
-show => '*',
)->pack();
my $button1 = $fenetre->Button(
-text => "Se connecter",
-command => [ \&ClientMail, $fenetre, $host, $login, $pass ],
)->pack();
my $button2 = $fenetre->Button(
-text => "Quitter",
-command => \&Quitter,
)->pack();
MainLoop();
sub ClientMail {
my ( $fenetre, $EntryHost, $EntryLogin, $EntryPass ) = @_;
my $host = $EntryHost->get;
my $user = $EntryLogin->get;
my $pass = $EntryPass->get;
#########################
# Fin declaration fonctions et variables
my $fen = MainWindow->new(); #Création de la fenêtre principale
$fen->title("Client Mail"); #Définition du title de la fenêtre
$fen->minsize( '500', '400' );
# destruction de la fenetre principale
$fenetre->destroy;
my $pop = Net::POP3->new($host) or die("ERROR: Unable to connect.\n");
# login
my $numMsg = $pop->login( $user, $pass ) or die("ERROR: Unable to login.\n");
#Création de la barre de menu
my $barre_menu = $fen->Frame( -relief => 'groove', -borderwidth => 2 );
#Création de la barre du menu général
my $menu_app = $barre_menu->Menubutton(
-text => 'Fichier', #Définition du libellé du bouton
-font => '{Garamond} 10', #Définition de la police
-tearoff => 0,
-menuitems => [ #Ajout des items au menu
[ 'command' => 'Quitter',
-font => '{Garamond} 10',
-command => \&Quitter, #Cette définition appelle Quitter
]
]
);
#Affichage du menu général à gauche
$menu_app->pack( -side => 'left' );
#Affichage de la barre de menu en haut et sur toute la largeur de la fenêtre
$barre_menu->pack( -side => 'top', -anchor => 'n', -fill => 'x' );
#Creation des boutons notebook
my $book = $fen->NoteBook()->pack( -fill => 'both', -expand => 1 );
my $tab1 = $book->add( "Sheet 1", -label => "LOGIN" );
my $tab2 = $book->add( "Sheet 2", -label => "INBOX" );
my $tab3 = $book->add( "Sheet 3", -label => "Informations" );
## j'ai voulu ajouter le login dans un "slide" mais je ne sais pas stocker en session les infos ###
# Création de deux lignes de "dialogue"
my $w_entry1 = $tab1->Entry( -text => 'user@sample.org' );
$w_entry1->pack( -padx => 10, -pady => 10 )->focus;
my $w_entry2 = $tab1->Entry( -text => 'password', -show => '*' );
$w_entry2->pack( -padx => 10, -pady => 10 );
my $sessionUser;
my $sessionPass;
$tab1->Button(
-text => "Se connecter",
-command => sub {
my $sessionUser = $w_entry1->get;
$tab1->Label( -text => "Connecte en tant que " . $sessionUser )->pack( -expand => 1 );
my $sessionPass = $w_entry2->get;
},
)->pack( -padx => 10, -pady => 10 );
$tab2->Label( -text => "Bienvenue" )->pack( -expand => 1 );
my $output_frame = $tab2->Frame()->pack( -side => "bottom" );
my $output_scroll = $output_frame->Scrollbar();
my $output_text = $output_frame->Text( -yscrollcommand => [ 'set', $output_scroll ] );
$output_scroll->configure( -command => [ 'yview', $output_text ] );
$output_scroll->pack( -side => "right", -expand => "no", -fill => "y" );
$output_text->pack();
my $sizeBox = $pop->list($numMsg);
$tab3->Label( -text => "Il y a actuellement "
. $numMsg
. " messages dans votre boite. \n\n La taille de votre boite est de "
. $sizeBox
. " octets." )->pack( -expand => 1 );
# close connection
$pop->quit();
return;
}
sub Quitter {
exit(0);
} |