Protocol-OTR
view release on metacpan or search on metacpan
lib/Protocol/OTR/Account.pm view on Meta::CPAN
}
sub contact {
my $self = shift;
my ($name, $fingerprint, $is_verified) = validate_pos(
@_,
{
type => SCALAR,
},
{
type => SCALAR,
optional => 1,
},
{
type => BOOLEAN,
optional => 1,
}
);
return Protocol::OTR::Contact->_new(
$self,
{
name => $name,
fingerprint => $fingerprint,
is_verified => $is_verified,
}
);
}
sub contacts {
my ($self) = @_;
return map {
Protocol::OTR::Contact->_new($self, { name => $_ } )
} @{ $self->_contacts() }
}
1;
__END__
=pod
=encoding UTF-8
=head1 NAME
Protocol::OTR::Account - Off-the-Record Account (private key)
=head1 VERSION
version 0.05
=head1 SYNOPSIS
use Protocol::OTR qw( :constants );
my $otr = Protocol::OTR->new(
{
privkeys_file => "otr.private_key",
contacts_file => "otr.fingerprints",
instance_tags_file => "otr.instance_tags",
}
);
# find or create account
my $alice = $otr->account('alice@domain', 'prpl-jabber');
print "Account:\n";
print " * name: ", $alice->name, "\n";
print " * protocol: ", $alice->protocol, "\n";
print " * fingerprint: ", $alice->fingerprint, "\n";
# find or create contact known by $alice
my $bob = $alice->contact('bob@domain');
# return all known by $alice contacts
my @contacts = $alice->contacts();
=head1 DESCRIPTION
L<Protocol::OTR::Account> represents the OTR account (private key).
=head1 METHODS
=head2 ctx
my $otr = $account->ctx();
Returns account's context.
=head2 name
my $name = $account->name();
Returns account's name.
=head2 protocol
my $protocol = $account->protocol();
Returns account's protocol.
=head2 fingerprint
my $fingerprint = $account->fingerprint();
Returns account's fingerprint in human readable format
C<12345678 90ABCDEF 12345678 90ABCDEF 12345678>.
=head2 contact
my $contact = $account->contact( $name, [ $fingerprint, [ $is_verified ]]);
Returns existing or creates new L<Protocol::OTR::Contact> object.
If C<$fingeprint> is set for contact, it will be set as C<verified> if
C<$is_verified> is true.
Note: it is allowed to use a string of 40 chars or human readable format (44 chars).
( run in 1.619 second using v1.01-cache-2.11-cpan-39bf76dae61 )