[prev in list] [next in list] [prev in thread] [next in thread] 

List:       perl-mailbox
Subject:    Re: My overall structure
From:       Mark Overmeer <Mark () Overmeer ! net>
Date:       2002-06-21 6:05:08
[Download RAW message or body]

* Scott Penrose (scottp@dd.com.au) [020621 00:02]:
> We wrote this so that we could have the one bit of code manipulating 
> remote pop and imap folders, local maildir folders and news articles. It 
> means that our portal code only had to have the one threaded lister and 
> mail viewer for both news and email.
> I am wondering, how close will I get to replacing all of that with 
> Mail::Box ?

All Mail::Box folder types have exactly the same basic interface for
handling messages.  For what I have seen from the IMAP and POP protocols,
everything is in there to seemlessly insert them into the tree.

For the listener: it is not in Mail::Box itself, but should be done
in the application program.  Maybe contributed in the scripts/
directory ;)  It could be done like this:

   my $mgr   = Mail::Box::Manager->new;
   my $pop   = $mgr->open(..., type => 'pop3', ...);
   my $inbox = $mgr->open(..., type => 'mh');
   my $imap  = $mgr->open(..., type => 'imap');

   while(1)
   {   # Scan for new things in the folders

       # Ask to read newly arrived messages
       $pop->update;
       $inbox->update;
       $imap->update;
   }

Something like that.

> My main question is around multiple folders and single connections. In 
> the IMAP case, it is important that you only make one connection to the 
> IMAP server for all of the folders you may open and manipulate. If you 
> had to open connections for every folder that would be slow, and more 
> than likely impossible.

There is not IMAP implementation yet, so...
I believe opening can be smart:

   my $imap = $mgr->open(host => ...);

calls Mail::Box::IMAP::init

   my %connections;
   sub init($)
   {   my ($self, $args) = @_;
       $self->SUPER::init($args);

       $connections{$args{$host}} ||= $self->createConnection($host);
       $self;
   }

Not too hard, I think, and no user can accidentally create multiple
connections in the same program.

>                              Also having the single API for listing, 
> creating, renaming, moving folders is important to us.

That's the thing I will gard with my life!

>                                                      Eventually we 
> need the one interface for filter rules too - but that is off in the 
> distance.

Filter rule interface already exists in Mail::Box::Search

> So - do you think Mail::Box is the right place for this, or is it really 
> around the single folder metaphor ?

No: multi-folder for sure.  That's why the Mail::Box::Manager is so
important.
-- 
               MarkOv       %-]

------------------------------------------------------------------------
drs Mark A.C.J. Overmeer                                MARKOV Solutions
       Mark@Overmeer.net                          solutions@overmeer.net
http://Mark.Overmeer.net                   http://solutions.overmeer.net


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic