mirror of
https://github.com/irssi/irssi.git
synced 2024-12-04 14:46:39 -05:00
parent
1f42d2aa95
commit
ca5e9bd623
@ -30,6 +30,7 @@ $VERSION = "2.92";
|
|||||||
# Check /mailbox help for help.
|
# Check /mailbox help for help.
|
||||||
|
|
||||||
use Irssi::TextUI;
|
use Irssi::TextUI;
|
||||||
|
use Irssi;
|
||||||
|
|
||||||
my $maildirmode = 0; # maildir=1, file(spools)=0
|
my $maildirmode = 0; # maildir=1, file(spools)=0
|
||||||
my $old_is_not_new = 0;
|
my $old_is_not_new = 0;
|
||||||
@ -37,7 +38,7 @@ my $extprog;
|
|||||||
my ($last_refresh_time, $refresh_tag);
|
my ($last_refresh_time, $refresh_tag);
|
||||||
|
|
||||||
# for mbox caching
|
# for mbox caching
|
||||||
my $last_size, $last_mtime, $last_mailcount, $last_mode;
|
my ($last_size, $last_mtime, $last_mailcount, $last_mode);
|
||||||
|
|
||||||
# list of mailboxes
|
# list of mailboxes
|
||||||
my %mailboxes = ();
|
my %mailboxes = ();
|
||||||
@ -101,8 +102,9 @@ sub mbox_count {
|
|||||||
my $old_is_not_new=Irssi::settings_get_bool('mail_oldnotnew');
|
my $old_is_not_new=Irssi::settings_get_bool('mail_oldnotnew');
|
||||||
|
|
||||||
if ($extprog ne "") {
|
if ($extprog ne "") {
|
||||||
$total = `$extprog`;
|
my $total = `$extprog`;
|
||||||
chomp $unread;
|
chomp $total;
|
||||||
|
($read, $unread) = split ' ', $total, 2;
|
||||||
} else {
|
} else {
|
||||||
if (!$maildirmode) {
|
if (!$maildirmode) {
|
||||||
if (-f $mailfile) {
|
if (-f $mailfile) {
|
||||||
@ -115,8 +117,7 @@ sub mbox_count {
|
|||||||
$last_size = $size;
|
$last_size = $size;
|
||||||
$last_mtime = $mtime;
|
$last_mtime = $mtime;
|
||||||
|
|
||||||
my $f = gensym;
|
return 0 if (!open(my $f, "<", $mailfile));
|
||||||
return 0 if (!open($f, "<", $mailfile));
|
|
||||||
|
|
||||||
# count new mails only
|
# count new mails only
|
||||||
my $internal_removed = 0;
|
my $internal_removed = 0;
|
||||||
@ -205,7 +206,7 @@ sub mail {
|
|||||||
my $total = 0;
|
my $total = 0;
|
||||||
|
|
||||||
# check all mailboxes for new email
|
# check all mailboxes for new email
|
||||||
foreach $name (keys(%mailboxes)) {
|
foreach my $name (keys(%mailboxes)) {
|
||||||
my $box = $mailboxes{$name};
|
my $box = $mailboxes{$name};
|
||||||
# replace "~/" at the beginning by the user's home dir
|
# replace "~/" at the beginning by the user's home dir
|
||||||
$box =~ s/^~\//$ENV{'HOME'}\//;
|
$box =~ s/^~\//$ENV{'HOME'}\//;
|
||||||
@ -233,7 +234,7 @@ sub mail {
|
|||||||
# Show this only if there are any new, unread messages.
|
# Show this only if there are any new, unread messages.
|
||||||
if (Irssi::settings_get_bool('mail_show_message') &&
|
if (Irssi::settings_get_bool('mail_show_message') &&
|
||||||
$unread > $new_mails_in_box{$name}) {
|
$unread > $new_mails_in_box{$name}) {
|
||||||
$new_mails = $unread - $new_mails_in_box{$name};
|
my $new_mails = $unread - $new_mails_in_box{$name};
|
||||||
if ($nummailboxes == 1) {
|
if ($nummailboxes == 1) {
|
||||||
Irssi::print("You have $new_mails new message" . ($new_mails != 1 ? "s." : "."), MSGLEVEL_CRAP);
|
Irssi::print("You have $new_mails new message" . ($new_mails != 1 ? "s." : "."), MSGLEVEL_CRAP);
|
||||||
} else {
|
} else {
|
||||||
@ -263,11 +264,9 @@ sub add_mailboxes {
|
|||||||
my $boxstring = $_[0];
|
my $boxstring = $_[0];
|
||||||
my @boxes = split(/,/, $boxstring);
|
my @boxes = split(/,/, $boxstring);
|
||||||
|
|
||||||
foreach $dbox(@boxes) {
|
foreach my $dbox(@boxes) {
|
||||||
my $name = $dbox;
|
my $name = substr($dbox, 0, index($dbox, '='));
|
||||||
$name = substr($dbox, 0, index($dbox, '='));
|
my $box = substr($dbox, index($dbox, '=') + 1, length($dbox));
|
||||||
my $box = $dbox;
|
|
||||||
$box = substr($dbox, index($dbox, '=') + 1, length($dbox));
|
|
||||||
addmailbox($name, $box);
|
addmailbox($name, $box);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -306,7 +305,7 @@ sub delmailbox {
|
|||||||
sub update_settings_string {
|
sub update_settings_string {
|
||||||
my $setting;
|
my $setting;
|
||||||
|
|
||||||
foreach $name (keys(%mailboxes)) {
|
foreach my $name (keys(%mailboxes)) {
|
||||||
$setting .= $name . "=" . $mailboxes{$name} . ",";
|
$setting .= $name . "=" . $mailboxes{$name} . ",";
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -345,7 +344,7 @@ sub cmd_showmailboxes {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Irssi::print("Mailboxes:", MSGLEVEL_CRAP);
|
Irssi::print("Mailboxes:", MSGLEVEL_CRAP);
|
||||||
foreach $box (keys(%mailboxes)) {
|
foreach my $box (keys(%mailboxes)) {
|
||||||
Irssi::print("$box: " . $mailboxes{$box}, MSGLEVEL_CRAP);
|
Irssi::print("$box: " . $mailboxes{$box}, MSGLEVEL_CRAP);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user