JaM
view release on metacpan or search on metacpan
lib/JaM/GUI/Compose.pm view on Meta::CPAN
# set the locale to RFC822's
POSIX::setlocale (LC_TIME, "en");
# generate the local time string
$date = POSIX::strftime ("%a, %e %b %Y %T %z", localtime($now));
# revert the locale
POSIX::setlocale (LC_TIME, $oldlocale);
return $date;
}
sub close {
my $self = shift;
$self->gtk_win->destroy;
}
sub insert_reply_message {
my $self = shift;
my %par = @_;
my ($mail, $reply_all, $reply_group) =
@par{'mail','reply_all','reply_group'};
my $mail_comp = $self->comp('mail');
my $mail_as_text = JaM::GUI::MailAsText->new;
my $from = $mail->head_get_decoded('from');
$from =~ s/<.*?>//;
$from =~ s/\s+/ /g;
$from =~ s/\s$//;
if ( $from eq "" ) {
$from = $mail->head_get_decoded('from');
$from =~ s/<//;
$from =~ s/>//;
}
$mail_as_text->begin;
$mail_as_text->write ("$from wrote:\n\n");
$mail_as_text->quote(1);
$mail_as_text->wrap_length($self->config('wrap_line_length_send'));
if ( $mail->body ) {
my $data = $mail->body->as_string;
$data =~ s/^\s+//;
$mail_comp->put_mail_text (
widget => $mail_as_text,
data => $data,
no_table => 1,
);
}
$mail_comp->print_child_entities (
first_time => 1,
widget => $mail_as_text,
entity => $mail,
wrap_length => $self->config('wrap_line_length_send'),
quote => 1,
);
my $text = $self->gtk_text;
my $charset = $mail->head->mime_attr('content-type.charset');
if ( $charset =~ /^utf-?8$/i ) {
$self->message_window (
message => "Warning:\n\n".
"Reply message was converted from\n".
"UTF-8 to ISO-8859-1.",
);
require Unicode::String;
my $content = Unicode::String::utf8($mail_as_text->text);
$text->insert (undef, undef, undef, $content->latin1);
} else {
$text->insert (undef, undef, undef, $mail_as_text->text);
}
my $subject = $mail->joined_head('subject');
$subject = "Re: $subject" if $subject !~ /^(Re|Aw):/i;
$self->gtk_subject->set_text ($subject);
my $ignore_reply_to = $self->comp('folders')->selected_folder_object
->ignore_reply_to;
my @to_header;
if ( $reply_all ) {
# write the to_header "hash" as a list to preserve
# order. later we shift pairs from the list.
@to_header = (
"reply-to" => 'To',
from => 'To',
to => 'CC',
cc => 'CC',
);
} elsif ( $reply_group ) {
if ( $mail->head_get("cc") ) {
@to_header = ( cc => 'To' );
} else {
@to_header = ( to => 'To' );
}
push @to_header, ( "reply-to" => "CC" ) if $mail->head_get("reply-to");
} elsif ( not $ignore_reply_to
and $mail->head_get("reply-to") ) {
@to_header = (
"reply-to" => 'To',
);
} else {
@to_header = (
from => 'To',
);
}
my $gtk_to_entries = $self->gtk_to_entries;
my $gtk_to_options = $self->gtk_to_options;
my $to_header_choices = $self->to_header_choices;
my @values;
my $value;
my $no_reply_regex =
( run in 0.814 second using v1.01-cache-2.11-cpan-d7f47b0818f )