[Bps-public-commit] r18892 - in Net-IMAP-Server: lib/Net/IMAP/Server lib/Net/IMAP/Server/Command

alexmv at bestpractical.com alexmv at bestpractical.com
Fri Mar 20 14:15:05 EDT 2009


Author: alexmv
Date: Fri Mar 20 14:15:04 2009
New Revision: 18892

Modified:
   Net-IMAP-Server/   (props changed)
   Net-IMAP-Server/lib/Net/IMAP/Server/Command/Select.pm
   Net-IMAP-Server/lib/Net/IMAP/Server/Mailbox.pm

Log:
 r43450 at kohr-ah:  chmrr | 2009-03-20 14:11:07 -0400
 The UNSEEN of SELECT is different from the UNSEEN of STATUS.  Split
 the former into ->first_unseen.  Also, ->first_unseen is 0 if there
 are no unseen messages.


Modified: Net-IMAP-Server/lib/Net/IMAP/Server/Command/Select.pm
==============================================================================
--- Net-IMAP-Server/lib/Net/IMAP/Server/Command/Select.pm	(original)
+++ Net-IMAP-Server/lib/Net/IMAP/Server/Command/Select.pm	Fri Mar 20 14:15:04 2009
@@ -35,8 +35,8 @@
     $self->untagged_response( $mailbox->exists . ' EXISTS' );
     $self->untagged_response( $mailbox->recent . ' RECENT' );
 
-    my $unseen = $mailbox->unseen;
-    $self->untagged_response("OK [UNSEEN $unseen]") if defined $unseen;
+    my $unseen = $mailbox->first_unseen;
+    $self->untagged_response("OK [UNSEEN $unseen]");
 
     my $uidvalidity = $mailbox->uidvalidity;
     $self->untagged_response("OK [UIDVALIDITY $uidvalidity]")

Modified: Net-IMAP-Server/lib/Net/IMAP/Server/Mailbox.pm
==============================================================================
--- Net-IMAP-Server/lib/Net/IMAP/Server/Mailbox.pm	(original)
+++ Net-IMAP-Server/lib/Net/IMAP/Server/Mailbox.pm	Fri Mar 20 14:15:04 2009
@@ -341,8 +341,7 @@
         } elsif ( $i eq "RECENT" ) {
             $items{$i} = $self->recent;
         } elsif ( $i eq "UNSEEN" ) {
-            my $unseen = $self->unseen;
-            $items{$i} = $unseen if defined $unseen;
+            $items{$i} = $self->unseen;
         } elsif ( $i eq "UIDVALIDITY" ) {
             my $uidvalidity = $self->uidvalidity;
             $items{$i} = $uidvalidity if defined $uidvalidity;
@@ -462,15 +461,15 @@
     return scalar grep { $_->has_flag('\Recent') } @{ $self->messages };
 }
 
-=head3 unseen
+=head3 first_unseen
 
-Returns the sequence number of the first messages which does not have
-the C<\Seen> flag set.  Returns undef if all messages have been marked
-as C<\Seen>.
+Returns the sequence number of the first message which does not have
+the C<\Seen> flag set.  Returns 0 if all messages have been marked as
+C<\Seen>.
 
 =cut
 
-sub unseen {
+sub first_unseen {
     my $self = shift;
     for ( @{ $self->messages } ) {
         next if $_->has_flag('\Seen');
@@ -478,7 +477,18 @@
             ? Net::IMAP::Server->connection->sequence($_)
             : $_->sequence;
     }
-    return undef;
+    return 0;
+}
+
+=head3 unseen
+
+Returns the number of messages which have the C<\Seen> flag set.
+
+=cut
+
+sub unseen {
+    my $self = shift;
+    return scalar grep { $_->has_flag('\Seen') } @{ $self->messages };
 }
 
 =head3 permanentflags



More information about the Bps-public-commit mailing list