=================================================================== RCS file: /cvs/palm/Palm-Keyring/examples/example3.pl,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- palm/Palm-Keyring/examples/example3.pl 2007/01/28 16:17:54 1.1 +++ palm/Palm-Keyring/examples/example3.pl 2007/01/30 04:59:55 1.2 @@ -7,7 +7,7 @@ use YAML; -use lib 'lib'; +use Palm::PDB; use Palm::Keyring; my $Default_File = $ENV{'HOME'} . '/.jpilot/Keys-Gtkr.pdb'; @@ -26,7 +26,7 @@ ); $PDBFile ||= $Default_File; -my $pdb = new Palm::Keyring(); +my $pdb = new Palm::PDB(); $pdb->Load($PDBFile) || die "Couldn't load '$PDBFile': $!"; if ($Action_List) { @@ -42,30 +42,12 @@ exit; -#$pdb->Decrypt('12345'); -#print Dump $pdb; - -#-------------------------------------------------- -# my $new_record = $pdb->append_Record(); -# -# $new_record->{plaintext} = { -# name => 'Test3', -# account => 'anothertestaccount', -# password => 'adifferentmypass', -# description => 'now that really roxorZ!', -# }; -# -#$pdb->Encrypt('12345'); -# -#$pdb->Write("Keys-GtkrNEW.PDB"); -#-------------------------------------------------- - - sub show_list { print "Showing List\n"; - foreach my $r (@{ $pdb->{'records'} }) { - next unless $r->{'plaintext'}; + foreach (0..$#{ $pdb->{'records'} }) { + next if $_ == 0; + my $r = $pdb->{'records'}->[$_]; my $category = $pdb->{'appinfo'}->{'categories'}->[ $r->{'category'} ]->{'name'}; @@ -74,12 +56,12 @@ $matched++ if uc($category) eq uc($cat); } foreach my $name (@{ $Names}) { - $matched++ if uc($r->{'plaintext'}->{'name'}) eq uc($name); + $matched++ if uc($r->{'data'}) eq uc($name); } next if ( @{ $Categories } || @{ $Names } ) && not $matched; # XXX Fix up formatting - print $r->{'plaintext'}->{'name'} . + print $r->{'data'} . ":" . $r->{'category'} . ":" . @@ -100,10 +82,12 @@ sub show_items { - decrypt() || die "Couldn't decrypt file!"; + get_password() || die "Couldn't decrypt file!"; - foreach my $r (@{ $pdb->{'records'} }) { - next unless $r->{'plaintext'}; + foreach (0..$#{ $pdb->{'records'} }) { + next if $_ == 0; + my $r = $pdb->{'records'}->[$_]; + my $category = $pdb->{'appinfo'}->{'categories'}->[ $r->{'category'} ]->{'name'}; @@ -112,22 +96,18 @@ $matched++ if uc($category) eq uc($cat); } foreach my $name (@{ $Names}) { - $matched++ if uc($r->{'plaintext'}->{'name'}) eq uc($name); + $matched++ if uc($r->{'data'}) eq uc($name); } next if ( @{ $Categories } || @{ $Names } ) && not $matched; + my $a = $pdb->Decrypt($r); + # XXX Fix up formatting - print $r->{'plaintext'}->{'name'} . - "\n\t" . - "Category: " . $category . - "\n\t" . - "Account: " . $r->{'plaintext'}->{'account'} . - "\n\t" . - "Password: " . $r->{'plaintext'}->{'password'} . - "\n"; - print "\tDescription: " . $r->{'plaintext'}->{'description'} . "\n" - if $r->{'plaintext'}->{'description'}; - + print $r->{'data'} . "\n\t" . + "Category: " . $category . "\n\t" . + "Account: " . $a->{'account'} . "\n\t" . + "Password: " . $a->{'password'} . "\n"; + print "\tNotes: " . $a->{'notes'} . "\n" if $a->{'notes'}; } } @@ -142,7 +122,7 @@ die "not implemented!"; } -sub decrypt +sub get_password { while (1) { print "Enter Password: "; @@ -156,7 +136,7 @@ $read =~ s/\s*$//; #return 1 if - $pdb->Decrypt($read) && return 1; + $pdb->Password($read) && return 1; #print Dump $read, $pdb; #exit; }