| version 1.3, 2006/04/18 20:39:45 |
version 1.4, 2006/06/13 01:03:39 |
|
|
| #!/usr/bin/perl
|
#!/usr/bin/perl
|
| # $RedRiver: palmkeyring-tk,v 1.2 2006/02/02 00:59:08 andrew Exp $
|
# $RedRiver: palmkeyring-tk,v 1.3 2006/04/18 19:39:45 andrew Exp $
|
| ########################################################################
|
########################################################################
|
| # palmkeyring-tk *** A GUI for 'Keyring for PalmOS' written in perl
|
# palmkeyring-tk *** A GUI for 'Keyring for PalmOS' written in perl
|
| #
|
#
|
|
|
| use lib 'lib';
|
use lib 'lib';
|
| use Palm::Keyring;
|
use Palm::Keyring;
|
|
|
|
| #my $File = "Keys-Gtkr.PDB";
|
|
| my $File = "k:/working/Keys-Gtkr.PDB";
|
|
| my $Keyring = _do_open($File);
|
|
|
|
|
| my $NAME = 'Palm Keyring';
|
my $NAME = 'Palm Keyring';
|
| |
my $VERSION = 0.01;
|
|
|
|
| |
my $File = shift || "Keys-Gtkr.PDB";
|
| |
my $Keyring = Open($File);
|
| |
|
| |
|
| my $lock_when = 0;
|
my $lock_when = 0;
|
| my $unlocked = time; # Change this to 0 when I get more stuff filled out
|
my $unlocked = time; # Change this to 0 when I get more stuff filled out
|
| my $lock_timeout = 30;
|
my $lock_timeout = 30;
|
|
|
|
| my $MW = MainWindow->new();
|
build_window();
|
| $MW->optionAdd('*BorderWidth' => 1);
|
MainLoop;
|
|
|
|
| my $pane = $MW->Panedwindow(
|
|
| Name => 'main',
|
|
| -showhandle => 1,
|
|
| -orient => 'horizontal'
|
|
| )->pack(-fill => 'both', -expand => 1);
|
|
|
|
|
| my $lists_frame = $pane->Frame(Name => 'lists')
|
|
| ->pack(-side=>'top',-anchor=>'nw',-fill=>'x');
|
|
| my $right_frame = $pane->Frame(Name => 'right',-relief=>'sunken')
|
|
| ->pack(-side=>'top',-anchor=>'ne',-fill=>'both',-expand=>1);
|
|
|
|
|
| my $account_frame = $right_frame->Frame(Name => 'account')
|
|
| ->pack(-side=>'top',-anchor=>'nw',-fill=>'both',-expand=>1);
|
|
| my $lock_frame = $right_frame->Frame(Name => 'lock',-relief=>'raised')
|
|
| ->pack(-side=>'bottom',-fill=>'x');
|
|
|
|
|
| $pane->add('.main.lists');
|
sub build_window
|
| $pane->add('.main.right');
|
{
|
|
|
|
| |
my $MW = MainWindow->new();
|
| |
$MW->optionAdd('*BorderWidth' => 1);
|
| |
|
| |
my $pane = $MW->Panedwindow(
|
| |
Name => 'main',
|
| |
-showhandle => 1,
|
| |
-orient => 'horizontal'
|
| |
)->pack(-fill => 'both', -expand => 1);
|
| |
|
| |
my $lists_frame = $pane->Frame(Name => 'lists')
|
| |
->pack(-side=>'top',-anchor=>'nw',-fill=>'x');
|
| |
my $right_frame = $pane->Frame(Name => 'right',-relief=>'sunken')
|
| |
->pack(-side=>'top',-anchor=>'ne',-fill=>'both',-expand=>1);
|
| |
|
| |
my $account_frame = $right_frame->Frame(Name => 'account')
|
| |
->pack(-side=>'top',-anchor=>'nw',-fill=>'both',-expand=>1);
|
| |
my $lock_frame = $right_frame->Frame(Name => 'lock',-relief=>'raised')
|
| |
->pack(-side=>'bottom',-fill=>'x');
|
| |
|
| |
$pane->add('.main.lists');
|
| |
$pane->add('.main.right');
|
| |
|
| # Lists
|
# Lists
|
| my $category_list = $lists_frame->BrowseEntry()->pack(-side=>'top',-fill=>'x');
|
my $category_list = $lists_frame->BrowseEntry()
|
| $category_list->insert(-1, 'All');
|
->pack(-side=>'top',-fill=>'x');
|
| my $accounts_list = $lists_frame->Scrolled('Listbox', -scrollbars => 'e')
|
$category_list->insert(-1, 'All');
|
| ->pack(-side=>'top',-fill=>'both',-expand=>1);
|
my $accounts_list = $lists_frame->Scrolled('Listbox', -scrollbars => 'e')
|
| |
->pack(-side=>'top',-fill=>'both',-expand=>1);
|
|
|
|
|
|
|
| # Account
|
# Account
|
| my %account_entry;
|
my %account_entry;
|
| foreach my $label (qw/Category Name Account Password/) {
|
foreach my $label (qw/Category Name Account Password/) {
|
| $account_entry{$label} = $account_frame->LabEntry(-state=>'readonly',
|
$account_entry{$label} = $account_frame->LabEntry(-state=>'readonly',
|
| -labelWidth => 10,
|
-labelWidth => 10,
|
| -labelPack => [-side => 'left', -anchor => 'w'],
|
-labelPack => [-side => 'left', -anchor => 'w'],
|
| -label=>$label . ': ', -text => 'my' . $label)
|
-label=>$label . ': ', -text => 'my' . $label)
|
| ->pack(-side=>'top',-anchor=>'nw',-fill=>'x');
|
->pack(-side=>'top',-anchor=>'nw',-fill=>'x');
|
| }
|
}
|
|
|
|
| $account_entry{'Details'} = $account_frame->ROText(-wrap => 'word',-height=>5,-width=>30)
|
$account_entry{'Details'} = $account_frame->ROText(-wrap => 'word',-height=>5,-width=>30)
|
| ->pack(-side=>'top',-anchor=>'nw',-fill=>'both',-expand=>1);
|
->pack(-side=>'top',-anchor=>'nw',-fill=>'both',-expand=>1);
|
| $account_entry{'Details'}->insert('1.0',"This is a test\nThis is only a test");
|
$account_entry{'Details'}->insert('1.0',"This is a test\nThis is only a test");
|
|
|
|
|
|
|
| # Lock
|
# Lock
|
| my $lock_button = $lock_frame->Button(-text => 'Lock', -command => \&Lock)
|
my $lock_button = $lock_frame->Button(-text => 'Lock', -command => \&Lock)
|
| ->pack(-side=>'left');
|
->pack(-side=>'left');
|
| my $lock_progress = $lock_frame->ProgressBar(
|
my $lock_progress = $lock_frame->ProgressBar(
|
| -variable=>\$lock_when,
|
-variable=>\$lock_when,
|
| -blocks => $lock_timeout,
|
-blocks => $lock_timeout,
|
| -from => $lock_timeout,
|
-from => $lock_timeout,
|
| -to => 0,
|
-to => 0,
|
| -gap => 0,
|
-gap => 0,
|
| )->pack(-side=>'right',-fill=>'x',-expand=>1,-padx=>5);
|
)->pack(-side=>'right',-fill=>'x',-expand=>1,-padx=>5);
|
|
|
|
| $lock_progress->repeat(500,\&Lock_Timeout);
|
$lock_progress->repeat(500,\&Lock_Timeout);
|
|
|
|
| my $menubar = build_menubar($MW);
|
my $menubar = build_menubar($MW);
|
|
|
|
| _populate_lists($Keyring, $category_list, $accounts_list);
|
_populate_lists($Keyring, $category_list, $accounts_list);
|
|
|
|
| my $VERSION = 0.01;
|
return $MW;
|
| |
}
|
|
|
|
| MainLoop;
|
|
|
|
|
|
|
|
| sub build_menubar {
|
sub build_menubar {
|
|
|
|
| # Create the menubar and File and Quit menubuttons. Note
|
my $MW = shift;
|
| # that the cascade's menu widget is automatically created.
|
|
|
|
|
| my $menubar = $MW->Menu;
|
# Create the menubar and File and Quit menubuttons. Note
|
| $MW->configure(-menu => $menubar);
|
# that the cascade's menu widget is automatically created.
|
| my $file = $menubar->cascade(-label => '~File', -tearoff => 0);
|
|
| my $help = $menubar->cascade(-label => '~Help', -tearoff => 0);
|
|
|
|
|
| # Create the menuitems for each menu. First, the File menu item.
|
my $menubar = $MW->Menu;
|
| |
$MW->configure(-menu => $menubar);
|
| |
my $file = $menubar->cascade(-label => '~File', -tearoff => 0);
|
| |
my $help = $menubar->cascade(-label => '~Help', -tearoff => 0);
|
|
|
|
| $file->command(-label => "Open", -command => \&Open);
|
# Create the menuitems for each menu. First, the File menu item.
|
| $file->command(-label => "Close", -command => \&Close);
|
|
| $file->command(-label => "Quit", -command => \&exit);
|
|
|
|
|
| # Finally, the Help menuitems.
|
$file->command(-label => "Open", -command => \&Open);
|
| |
$file->command(-label => "Close", -command => \&Close);
|
| |
$file->command(-label => "Quit", -command => \&exit);
|
|
|
|
| $help->command(-label => 'Version');
|
# Finally, the Help menuitems.
|
| $help->separator;
|
|
| $help->command(-label => 'About');
|
|
|
|
|
| my $ver_dialog = $MW->Dialog(-title => $NAME . ' Version',
|
$help->command(-label => 'Version');
|
| -text => "$NAME\n\nVersion $VERSION",
|
$help->separator;
|
| -buttons => ['OK'],
|
$help->command(-label => 'About');
|
| -bitmap => 'info');
|
|
| my $about_dialog = $MW->Dialog(-title => 'About ' . $NAME,
|
|
| -text => 'About ' . $NAME . "\n" .
|
|
| '© Copyright 2006 Andrew Fresh <andrew@mad-techies.org>',
|
|
| -buttons => ['OK']);
|
|
| my $menu = $help->cget('-menu');
|
|
| $menu->entryconfigure('Version', -command => [$ver_dialog => 'Show']);
|
|
| $menu->entryconfigure('About', -command => [$about_dialog => 'Show']);
|
|
|
|
|
| $menubar; # return the menubar
|
my $ver_dialog = $MW->Dialog(-title => $NAME . ' Version',
|
| |
-text => "$NAME\n\nVersion $VERSION",
|
| |
-buttons => ['OK'],
|
| |
-bitmap => 'info');
|
| |
my $about_dialog = $MW->Dialog(-title => 'About ' . $NAME,
|
| |
-text => 'About ' . $NAME . "\n" .
|
| |
'© Copyright 2006 Andrew Fresh <andrew@mad-techies.org>',
|
| |
-buttons => ['OK']);
|
| |
my $menu = $help->cget('-menu');
|
| |
$menu->entryconfigure('Version', -command => [$ver_dialog => 'Show']);
|
| |
$menu->entryconfigure('About', -command => [$about_dialog => 'Show']);
|
|
|
|
| |
$menubar; # return the menubar
|
| |
|
| }
|
}
|
|
|
|
| sub Lock
|
sub Lock
|
| {
|
{
|
| $unlocked = time;
|
$unlocked = time;
|
| }
|
}
|
|
|
|
| sub Lock_Timeout
|
sub Lock_Timeout
|
| {
|
{
|
| #return unless $unlocked;
|
#return unless $unlocked;
|
| my $diff = time - $unlocked;
|
my $diff = time - $unlocked;
|
| if ($diff > $lock_timeout) {
|
if ($diff > $lock_timeout) {
|
| print "Timed out!";
|
print "Timed out!";
|
| Tk::exit();
|
Tk::exit();
|
| } else {
|
Lock();
|
| $lock_when = $diff;
|
} else {
|
| }
|
$lock_when = $diff;
|
| |
}
|
| }
|
}
|
|
|
|
| sub Open
|
sub Open
|
| {
|
{
|
| |
my $file = shift;
|
| |
my $pdb = Palm::Keyring->new;
|
| |
$pdb->Load($file) || die "Couldn't load '$file'";
|
| |
return $pdb;
|
| }
|
}
|
|
|
|
| sub Close
|
sub Close
|
| {
|
{
|
| }
|
}
|
|
|
|
| sub _do_open
|
|
| {
|
|
| my $file = shift;
|
|
| my $pdb = Palm::Keyring->new;
|
|
| $pdb->Load($file) || die "Couldn't load '$file'";
|
|
| return $pdb;
|
|
| }
|
|
|
|
|
| sub _do_close
|
|
| {
|
|
| }
|
|
|
|
|
| sub _do_lock
|
|
| {
|
|
| }
|
|
|
|
|
| sub _populate_lists
|
sub _populate_lists
|
| {
|
{
|
| my $pdb = shift;
|
my $pdb = shift;
|
| my $cat = shift;
|
my $cat = shift;
|
| my $acct = shift;
|
my $acct = shift;
|
| foreach my $category (@{ $pdb->{'appinfo'}->{'categories'} }) {
|
foreach my $category (@{ $pdb->{'appinfo'}->{'categories'} }) {
|
| next unless $category->{'name'};
|
next unless $category->{'name'};
|
| $cat->insert( $category->{'id'}, $category->{'name'});
|
$cat->insert( $category->{'id'}, $category->{'name'});
|
| }
|
}
|
| foreach my $account (@{ $pdb->{'records'} }) {
|
foreach my $account (@{ $pdb->{'records'} }) {
|
| next unless $account->{'plaintext'}->{'name'};
|
next unless $account->{'plaintext'}->{'name'};
|
| $acct->insert('end', $account->{'plaintext'}->{'name'});
|
$acct->insert('end', $account->{'plaintext'}->{'name'});
|
| }
|
}
|
|
|
|
| }
|
}
|