=head1 NAME skximap::local - The local customisations for the IMAP server. =head1 DESCRIPTION This module contains code for presenting a data-based hierarchy of IMAP folders. This package is intentionally a little basic, but it contains the functions that the user of a real IMAP server would need to have to make their code work. =cut package skximap::local; use vars qw($VERSION @ISA @EXPORT @EXPORT_OK); require Exporter; require AutoLoader; @ISA = qw(Exporter AutoLoader); @EXPORT = qw(); ($VERSION) = '0.1'; use Email::Simple; =head2 new Create a new instance of this object. =cut sub new { my ( $proto, %supplied ) = (@_); my $class = ref($proto) || $proto; my $self = {}; bless( $self, $class ); return $self; } =begin doc This method should be return 1 if the given username & password pair are correct. Otherwise return 0. =end doc =cut sub login { my ( $self, $user, $passwd ) = (@_); if ( $user && $passwd && ( $user eq $passwd ) ) { return 1; } else { return 0; } } =begin doc Return an array of folders. Here we just return "INBOX" and one folder for each day of the current month/year. =end doc =cut sub get_folders { my ( $self, $login ) = (@_); my @folders = (); push @folders, "INBOX"; my ( $sec, $min, $hour, $mday, $mon, $year, $wday, $yday, $isdst ) = localtime(time); # # Update. # $mon += 1; $year += 1900; my @m = qw( NUL January February March April May June July August September October November December ); my $i = 1; while ( $i <= $mday ) { push( @folders, "$i-$m[$mon]-$year" ); $i += 1; } return sort @folders; } =begin doc We should return the count of (new+total) messages in folder. =end doc =cut sub count_messages { my ( $self, $username, $folder ) = (@_); return( 1, 1 ); } =begin doc Return a single message from the given folder. =end doc =cut sub get_message { my ( $self, $folder, $number ) = (@_); my $contents = ""; open( MSG, "<", "/tmp/msg.log" ); while () { # # Change subject. Just for fun # if ( $_ =~ /^Subject: (.*)/ ) { $_ = "Subject: From folder $folder\n"; } $contents .= $_; } close(MSG); my $email = Email::Simple->new($contents); return ($email); } 1;