/usr/share/perl5/Mail/Identity.pm is in libuser-identity-perl 0.98-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
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 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 | # Copyrights 2003-2017 by [Mark Overmeer <markov@cpan.org>].
# For other contributors see Changes.
# See the manual pages for details on the licensing terms.
# Pod stripped from pm file by OODoc 2.02.
package Mail::Identity;
use vars '$VERSION';
$VERSION = '0.98';
use base 'User::Identity::Item';
use strict;
use warnings;
use User::Identity;
use Scalar::Util 'weaken';
sub type() { "email" }
sub init($)
{ my ($self, $args) = @_;
$args->{name} ||= '-x-';
$self->SUPER::init($args);
exists $args->{$_} && ($self->{'MI_'.$_} = delete $args->{$_})
foreach qw/address charset comment domain language
location organization pgp_key phrase signature
username/;
$self->{UII_name} = $self->phrase || $self->address
if $self->{UII_name} eq '-x-';
$self;
}
sub from($)
{ my ($class, $other) = (shift, shift);
return $other if $other->isa(__PACKAGE__);
if($other->isa('Mail::Address'))
{ return $class->new
( phrase => $other->phrase
, address => $other->address
, comment => $other->comment
, @_);
}
if($other->isa('User::Identity'))
{ my $emails = $other->collection('emails') or next;
my @roles = $emails->roles or return ();
return $roles[0]; # first Mail::Identity
}
undef;
}
sub comment($)
{ my $self = shift;
return $self->{MI_comment} = shift if @_;
return $self->{MI_comment} if defined $self->{MI_comment};
my $user = $self->user or return undef;
my $full = $user->fullName or return undef;
$self->phrase eq $full ? undef : $full;
}
sub charset()
{ my $self = shift;
return $self->{MI_charset} if defined $self->{MI_charset};
my $user = $self->user or return undef;
$user->charset;
}
sub language()
{ my $self = shift;
return $self->{MI_language} if defined $self->{MI_language};
my $user = $self->user or return undef;
$user->language;
}
sub domain()
{ my $self = shift;
return $self->{MI_domain}
if defined $self->{MI_domain};
my $address = $self->{MI_address} or return 'localhost';
$address =~ s/.*?\@// ? $address : undef;
}
sub address()
{ my $self = shift;
return $self->{MI_address} if defined $self->{MI_address};
return $self->username .'@'. $self->domain
if $self->{MI_username} || $self->{MI_domain};
my $name = $self->name;
return $name if index($name, '@') >= 0;
my $user = $self->user;
defined $user ? $user->nickname : $name;
}
sub location()
{ my $self = shift;
my $location = $self->{MI_location};
if(! defined $location)
{ my $user = $self->user or return;
my @locs = $user->collection('locations');
$location = @locs ? $locs[0] : undef;
}
elsif(! ref $location)
{ my $user = $self->user or return;
$location = $user->find(location => $location);
}
$location;
}
sub organization()
{ my $self = shift;
return $self->{MI_organization} if defined $self->{MI_organization};
my $location = $self->location or return;
$location->organization;
}
#pgp_key
sub phrase()
{ my $self = shift;
return $self->{MI_phrase} if defined $self->{MI_phrase};
my $user = $self->user or return undef;
my $full = $user->fullName or return undef;
$full;
}
#signature
sub username()
{ my $self = shift;
return $self->{MI_username} if defined $self->{MI_username};
if(my $address = $self->{MI_address})
{ $address =~ s/\@.*$//; # strip domain part if present
return $address;
}
my $user = $self->user or return;
$user->nickname;
}
1;
|