Changeset eea7bed4 for perl/lib/BarnOwl
- Timestamp:
- Aug 16, 2017, 12:53:41 PM (7 years ago)
- Branches:
- master
- Children:
- ff528e6
- Parents:
- da7341e
- git-author:
- Jason Gross <jgross@mit.edu> (07/12/11 14:42:39)
- git-committer:
- Jason Gross <jasongross9@gmail.com> (08/16/17 12:53:41)
- Location:
- perl/lib/BarnOwl
- Files:
-
- 1 added
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
perl/lib/BarnOwl/Message.pm
r7f463cf reea7bed4 160 160 return $m->body; 161 161 } 162 } 163 164 =head2 log_filenames MESSAGE 165 166 Returns a list of filenames to which this message should be logged. 167 The filenames should be relative to the path returned by 168 C<log_base_path>. See L<BarnOwl::Logging::get_filenames> for the 169 specification of valid filenames, and for what happens if this 170 method returns an invalid filename. 171 172 =cut 173 174 sub log_filenames { 175 my ($m) = @_; 176 my $filename = lc($m->type); 177 $filename = "unknown" if !defined $filename || $filename eq ''; 178 if ($m->is_incoming && $m->pretty_sender) { 179 $filename .= ":" . $m->pretty_sender; 180 } elsif ($m->is_outgoing && $m->pretty_recipient) { 181 $filename .= ":" . $m->pretty_recipient; 182 } 183 return ($filename); 184 } 185 186 =head2 log_to_all_file MESSAGE 187 188 There is an C<all> file. This method determines if C<MESSAGE> 189 should get logged to it, in addition to any files returned by 190 C<log_filenames>. 191 192 It defaults to returning true if and only if C<MESSAGE> is outgoing. 193 194 =cut 195 196 sub log_to_all_file { 197 my ($m) = @_; 198 return $m->is_outgoing; 199 } 200 201 =head2 log_base_path MESSAGE 202 203 Returns the base path for logging, the folder in which all messages 204 of this class get logged. 205 206 Defaults to the BarnOwl variable C<logpath>. 207 208 =cut 209 210 sub log_base_path { 211 return BarnOwl::getvar('logpath'); 162 212 } 163 213 -
perl/lib/BarnOwl/Message/AIM.pm
r7011c3dc reea7bed4 24 24 } 25 25 26 sub normalize_screenname { 27 my ($screenname) = @_; 28 $screenname =~ s/\s+//g; 29 return lc($screenname); 30 } 31 32 sub log_filenames { 33 return map { normalize_screenname($_) } BarnOwl::Message::log_filenames(@_); 34 } 26 35 27 36 1; -
perl/lib/BarnOwl/Message/Zephyr.pm
r7f463cf reea7bed4 9 9 10 10 use base qw( BarnOwl::Message ); 11 use Unicode::Normalize qw( NFKC ); 11 12 12 13 sub strip_realm { … … 132 133 return $1 if $self->body =~ /^\s*cc:\s+([^\n]+)/i; 133 134 return undef; 135 } 136 137 sub zephyr_cc_without_recipient { 138 my $self = shift; 139 my $recipient = lc(strip_realm($self->recipient)); 140 my $cc = $self->zephyr_cc; 141 return grep { lc(strip_realm($_)) ne $recipient } split(/\s+/, $cc) if defined $cc; 142 return (); 134 143 } 135 144 … … 240 249 } 241 250 251 sub log_filenames { 252 my ($m) = @_; 253 my @filenames = (); 254 if ($m->is_personal) { 255 @filenames = $m->zephyr_cc_without_recipient; 256 } 257 if ($m->is_incoming) { 258 if ($m->is_personal) { 259 push @filenames, $m->sender; 260 } else { 261 return (lc(NFKC($m->class))); 262 } 263 } else { 264 push @filenames, $m->recipient; 265 } 266 return map { lc(NFKC(strip_realm($_))) } @filenames; 267 } 268 269 sub log_to_class_file { 270 my ($m) = @_; 271 return !$m->is_personal; 272 } 273 274 sub log_base_path { 275 my ($m) = @_; 276 if ($m->log_to_class_file) { 277 return BarnOwl::getvar('classlogpath'); 278 } else { 279 return BarnOwl::getvar('logpath'); 280 } 281 } 282 242 283 1;
Note: See TracChangeset
for help on using the changeset viewer.