| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
# Copyrights 2003-2022 by [Mark Overmeer ]. |
|
2
|
|
|
|
|
|
|
# For other contributors see ChangeLog. |
|
3
|
|
|
|
|
|
|
# See the manual pages for details on the licensing terms. |
|
4
|
|
|
|
|
|
|
# Pod stripped from pm file by OODoc 2.03. |
|
5
|
|
|
|
|
|
|
# This code is part of distribution User-Identity. Meta-POD processed with |
|
6
|
|
|
|
|
|
|
# OODoc into POD and HTML manual-pages. See README.md |
|
7
|
|
|
|
|
|
|
# Copyright Mark Overmeer. Licensed under the same terms as Perl itself. |
|
8
|
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
package Mail::Identity; |
|
10
|
1
|
|
|
1
|
|
6
|
use vars '$VERSION'; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
54
|
|
|
11
|
|
|
|
|
|
|
$VERSION = '1.01'; |
|
12
|
|
|
|
|
|
|
|
|
13
|
1
|
|
|
1
|
|
5
|
use base 'User::Identity::Item'; |
|
|
1
|
|
|
|
|
1
|
|
|
|
1
|
|
|
|
|
80
|
|
|
14
|
|
|
|
|
|
|
|
|
15
|
1
|
|
|
1
|
|
6
|
use strict; |
|
|
1
|
|
|
|
|
1
|
|
|
|
1
|
|
|
|
|
19
|
|
|
16
|
1
|
|
|
1
|
|
3
|
use warnings; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
39
|
|
|
17
|
|
|
|
|
|
|
|
|
18
|
1
|
|
|
1
|
|
6
|
use User::Identity; |
|
|
1
|
|
|
|
|
1
|
|
|
|
1
|
|
|
|
|
21
|
|
|
19
|
1
|
|
|
1
|
|
4
|
use Scalar::Util 'weaken'; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
1093
|
|
|
20
|
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
sub type() { "email" } |
|
23
|
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
sub init($) |
|
26
|
1
|
|
|
1
|
0
|
2
|
{ my ($self, $args) = @_; |
|
27
|
|
|
|
|
|
|
|
|
28
|
1
|
|
50
|
|
|
6
|
$args->{name} ||= '-x-'; |
|
29
|
|
|
|
|
|
|
|
|
30
|
1
|
|
|
|
|
5
|
$self->SUPER::init($args); |
|
31
|
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
exists $args->{$_} && ($self->{'MI_'.$_} = delete $args->{$_}) |
|
33
|
1
|
|
100
|
|
|
11
|
foreach qw/address charset comment domain language |
|
34
|
|
|
|
|
|
|
location organization pgp_key phrase signature |
|
35
|
|
|
|
|
|
|
username/; |
|
36
|
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
$self->{UII_name} = $self->phrase || $self->address |
|
38
|
1
|
50
|
0
|
|
|
5
|
if $self->{UII_name} eq '-x-'; |
|
39
|
|
|
|
|
|
|
|
|
40
|
1
|
|
|
|
|
2
|
$self; |
|
41
|
|
|
|
|
|
|
} |
|
42
|
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
sub from($) |
|
45
|
0
|
|
|
0
|
0
|
|
{ my ($class, $other) = (shift, shift); |
|
46
|
0
|
0
|
|
|
|
|
return $other if $other->isa(__PACKAGE__); |
|
47
|
|
|
|
|
|
|
|
|
48
|
0
|
0
|
|
|
|
|
if($other->isa('Mail::Address')) |
|
49
|
|
|
|
|
|
|
{ # Mail::Address is far to lazy |
|
50
|
0
|
|
|
|
|
|
return $class->parse($other->format); |
|
51
|
|
|
|
|
|
|
} |
|
52
|
|
|
|
|
|
|
|
|
53
|
0
|
0
|
|
|
|
|
if($other->isa('User::Identity')) |
|
54
|
0
|
0
|
|
|
|
|
{ my $emails = $other->collection('emails') or next; |
|
55
|
0
|
0
|
|
|
|
|
my @roles = $emails->roles or return (); |
|
56
|
0
|
|
|
|
|
|
return $roles[0]; # first Mail::Identity |
|
57
|
|
|
|
|
|
|
} |
|
58
|
|
|
|
|
|
|
|
|
59
|
0
|
|
|
|
|
|
undef; |
|
60
|
|
|
|
|
|
|
} |
|
61
|
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
sub comment($) |
|
64
|
0
|
|
|
0
|
1
|
|
{ my $self = shift; |
|
65
|
0
|
0
|
|
|
|
|
return $self->{MI_comment} = shift if @_; |
|
66
|
0
|
0
|
|
|
|
|
return $self->{MI_comment} if defined $self->{MI_comment}; |
|
67
|
|
|
|
|
|
|
|
|
68
|
0
|
0
|
|
|
|
|
my $user = $self->user or return undef; |
|
69
|
0
|
0
|
|
|
|
|
my $full = $user->fullName or return undef; |
|
70
|
0
|
0
|
|
|
|
|
$self->phrase eq $full ? undef : $full; |
|
71
|
|
|
|
|
|
|
} |
|
72
|
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
sub charset() |
|
75
|
0
|
|
|
0
|
1
|
|
{ my $self = shift; |
|
76
|
0
|
0
|
|
|
|
|
return $self->{MI_charset} if defined $self->{MI_charset}; |
|
77
|
|
|
|
|
|
|
|
|
78
|
0
|
0
|
|
|
|
|
my $user = $self->user or return undef; |
|
79
|
0
|
|
|
|
|
|
$user->charset; |
|
80
|
|
|
|
|
|
|
} |
|
81
|
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
sub language() |
|
84
|
0
|
|
|
0
|
1
|
|
{ my $self = shift; |
|
85
|
|
|
|
|
|
|
|
|
86
|
0
|
0
|
|
|
|
|
return $self->{MI_language} if defined $self->{MI_language}; |
|
87
|
|
|
|
|
|
|
|
|
88
|
0
|
0
|
|
|
|
|
my $user = $self->user or return undef; |
|
89
|
0
|
|
|
|
|
|
$user->language; |
|
90
|
|
|
|
|
|
|
} |
|
91
|
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
sub domain() |
|
94
|
0
|
|
|
0
|
1
|
|
{ my $self = shift; |
|
95
|
|
|
|
|
|
|
return $self->{MI_domain} |
|
96
|
0
|
0
|
|
|
|
|
if defined $self->{MI_domain}; |
|
97
|
|
|
|
|
|
|
|
|
98
|
0
|
0
|
|
|
|
|
my $address = $self->{MI_address} or return 'localhost'; |
|
99
|
0
|
0
|
|
|
|
|
$address =~ s/.*?\@// ? $address : undef; |
|
100
|
|
|
|
|
|
|
} |
|
101
|
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
sub address() |
|
104
|
0
|
|
|
0
|
1
|
|
{ my $self = shift; |
|
105
|
0
|
0
|
|
|
|
|
return $self->{MI_address} if defined $self->{MI_address}; |
|
106
|
|
|
|
|
|
|
|
|
107
|
0
|
0
|
|
|
|
|
if(my $username = $self->username) |
|
108
|
0
|
0
|
|
|
|
|
{ if(my $domain = $self->domain) |
|
109
|
0
|
0
|
|
|
|
|
{ if($username =~ /[^a-zA-Z0-9!#\$%&'*+\-\/=?^_`{|}~.]/) |
|
110
|
|
|
|
|
|
|
{ # When the local part does contain a different character |
|
111
|
|
|
|
|
|
|
# than an atext or dot, make it quoted-string |
|
112
|
0
|
|
|
|
|
|
$username =~ s/"/\\"/g; |
|
113
|
0
|
|
|
|
|
|
$username = qq{"$username"}; |
|
114
|
|
|
|
|
|
|
} |
|
115
|
0
|
|
|
|
|
|
return "$username\@$domain"; |
|
116
|
|
|
|
|
|
|
} |
|
117
|
|
|
|
|
|
|
} |
|
118
|
|
|
|
|
|
|
|
|
119
|
0
|
|
|
|
|
|
my $name = $self->name; |
|
120
|
0
|
0
|
|
|
|
|
return $name if index($name, '@') >= 0; |
|
121
|
|
|
|
|
|
|
|
|
122
|
0
|
|
|
|
|
|
my $user = $self->user; |
|
123
|
0
|
0
|
|
|
|
|
defined $user ? $user->nickname : $name; |
|
124
|
|
|
|
|
|
|
} |
|
125
|
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
|
|
127
|
|
|
|
|
|
|
sub location() |
|
128
|
0
|
|
|
0
|
1
|
|
{ my $self = shift; |
|
129
|
0
|
|
|
|
|
|
my $location = $self->{MI_location}; |
|
130
|
|
|
|
|
|
|
|
|
131
|
0
|
0
|
|
|
|
|
if(! defined $location) |
|
|
|
0
|
|
|
|
|
|
|
132
|
0
|
0
|
|
|
|
|
{ my $user = $self->user or return; |
|
133
|
0
|
|
|
|
|
|
my @locs = $user->collection('locations'); |
|
134
|
0
|
0
|
|
|
|
|
$location = @locs ? $locs[0] : undef; |
|
135
|
|
|
|
|
|
|
} |
|
136
|
|
|
|
|
|
|
elsif(! ref $location) |
|
137
|
0
|
0
|
|
|
|
|
{ my $user = $self->user or return; |
|
138
|
0
|
|
|
|
|
|
$location = $user->find(location => $location); |
|
139
|
|
|
|
|
|
|
} |
|
140
|
|
|
|
|
|
|
|
|
141
|
0
|
|
|
|
|
|
$location; |
|
142
|
|
|
|
|
|
|
} |
|
143
|
|
|
|
|
|
|
|
|
144
|
|
|
|
|
|
|
|
|
145
|
|
|
|
|
|
|
sub organization() |
|
146
|
0
|
|
|
0
|
1
|
|
{ my $self = shift; |
|
147
|
|
|
|
|
|
|
|
|
148
|
0
|
0
|
|
|
|
|
return $self->{MI_organization} if defined $self->{MI_organization}; |
|
149
|
|
|
|
|
|
|
|
|
150
|
0
|
0
|
|
|
|
|
my $location = $self->location or return; |
|
151
|
0
|
|
|
|
|
|
$location->organization; |
|
152
|
|
|
|
|
|
|
} |
|
153
|
|
|
|
|
|
|
|
|
154
|
|
|
|
|
|
|
#pgp_key |
|
155
|
|
|
|
|
|
|
|
|
156
|
|
|
|
|
|
|
sub phrase() |
|
157
|
0
|
|
|
0
|
1
|
|
{ my $self = shift; |
|
158
|
0
|
0
|
|
|
|
|
return $self->{MI_phrase} if defined $self->{MI_phrase}; |
|
159
|
0
|
0
|
|
|
|
|
my $user = $self->user or return undef; |
|
160
|
0
|
0
|
|
|
|
|
my $full = $user->fullName or return undef; |
|
161
|
0
|
|
|
|
|
|
$full; |
|
162
|
|
|
|
|
|
|
} |
|
163
|
|
|
|
|
|
|
|
|
164
|
|
|
|
|
|
|
#signature |
|
165
|
|
|
|
|
|
|
|
|
166
|
|
|
|
|
|
|
|
|
167
|
|
|
|
|
|
|
sub username() |
|
168
|
0
|
|
|
0
|
1
|
|
{ my $self = shift; |
|
169
|
0
|
0
|
|
|
|
|
return $self->{MI_username} if defined $self->{MI_username}; |
|
170
|
|
|
|
|
|
|
|
|
171
|
0
|
0
|
|
|
|
|
if(my $address = $self->{MI_address}) |
|
172
|
0
|
|
|
|
|
|
{ $address =~ s/\@.*$//; # strip domain part if present |
|
173
|
0
|
|
|
|
|
|
return $address; |
|
174
|
|
|
|
|
|
|
} |
|
175
|
|
|
|
|
|
|
|
|
176
|
0
|
0
|
|
|
|
|
my $user = $self->user or return; |
|
177
|
0
|
|
|
|
|
|
$user->nickname; |
|
178
|
|
|
|
|
|
|
} |
|
179
|
|
|
|
|
|
|
|
|
180
|
|
|
|
|
|
|
1; |
|
181
|
|
|
|
|
|
|
|