Re: Email::Address::XS

2016-08-22 Thread Ricardo Signes
* p...@cpan.org [2016-08-20T06:01:16]
> Email::MIME is module which automatically do any MIME encoding/decoding 
> without user interaction, so that decoding must be done automatically 
> and without such "upgrade" function.

So do you mean that whenever someone reads the header with a specific method,
the header is parsed just-in-time?

If so, this seems like something very easy to add in an Email::MIME subclass to
show it off.

Of course, it's also easy to take the hypothetical code behind
"upgrade_headers($email)" to do something just like this, on a per-known-header
basis.

> I do not want to do that decode manually or call some "upgrade" function 
> which you propose... Reading one email header should not change internal 
> email structure.

I never suggested that anything was changed by virtue of being read, but rather
that one could explictly upgrade structures if desired.

> Also it must be possible to get either named groups from Original-Cc 
> header or only list of addresses. And I think with your proposal API it 
> is not possible. You would need to call some "downgrade" function and 
> then "upgrade" it to another object or so...

Why would this not be possible?  There is some object storing the mailboxes
structure, and it provides methods that answer the questions one needs to ask.

-- 
rjbs


signature.asc
Description: Digital signature


Re: Email::Address::XS

2016-08-22 Thread Ricardo Signes
* p...@cpan.org [2016-08-18T17:35:10]
> On Thursday 18 August 2016 23:21:28 Ricardo Signes wrote:
> > As you say, 1 and 2 are dealt with.  For 3 or 4, you want to have an
> > object in the header slot, rather than a string.  Once you've done
> > that, you use its methods.  If the object's To field stores a
> > string, you "upgrade" it with something like:
> > 
> >   $email->header(To => mailbox_headers_from( $email->header('To') );
> > 
> > ...and it seems like one would quickly amass some sort of routine
> > like:
> > 
> >   upgrade_headers($email);
> > 
> > ...that would upgrade all the headers it knows about.
> 
> Can you describe (or write code) how you imagine that I get header 
> "Original-Cc" in form of addresses in list of named groups from email 
> which is stored in string scalar? I'm not sure that I understand how you 
> mean it...

Here's a verbose form:

  # Get an email.
  my $email   = get_some_email_mime();

  # Get the header -- the (unfolded) raw bytes.
  my $cc_hdr  = $email->header_raw('Original-CC');

  # parse it into an object
  my $cc_obj  = parse_mailboxes( $cc_obj );

  # put that object into the header:
  $email->header_set('Original-CC', $cc_obj);

  # get the raw mime-encoded bytes again:
  my $cc_hdr2 = $email->header_raw('Original-CC');

  # get a list of sub-object from the object's imaginary interface:
  my @boxes   = $email->header_obj('Original-CC')->boxes;

-- 
rjbs


signature.asc
Description: Digital signature