[Gambas-devel] About gb.net.pop3

Benoît Minisini gambas at ...1...
Fri Aug 31 20:17:43 CEST 2012


Le 31/08/2012 03:55, Sebastian Kulesz a écrit :
>>
>> I'm using plain Gambas. gmime is too complex and the specs don't
>> require anything that gambas can't do ;)
>>
>> The MIMEMessage class is independent, so that if we later
>> implement IMAP, for example, it can be done without additional
>> work.
>
> I like the changes :) One question only. When you reference $iPort
> to iPort (line Pop3Client:186) you are never telling the user which
> port is being used (even though it should be obvious). Is this
> intentional?

Mmm... Yes? The idea is that "zero" (which is never a valid port for a
standard protocol afaik) means "takes the default port". This is needed
the default port is different if you use encryption or not.

>
> Leaving POP3 aside, i just pushed an initial implementation of a
> MIME parser. It's far from complete, and the code is *really dirty*

Ouch....

> and unorganized, but it already has basic functionality. Right now it
> can only parse a message into a structure, not backwards, but this
> will come later. i'm having some trouble decoding Quoted-Printable
> content, but that's because i don't know much of regex. I found this
> one online, but i don't know much of the pcre component and how to
> directly replace matches, so i hardcoded it into a big loop but it
> is really buggy. I'd really thank some help here.
>
> regex: =([0-9a-fA-F]{2}) Quoted-Printable specs:
> http://tools.ietf.org/html/rfc2045#page-19

Aaarrgh... No regexp. Never use them for that! It's for Perl programmers 
and it's slow and it's buggy 99% of the time.

These routines must be implemented in C for speed reasons. The structure 
of the component should go there:

- A part in C with the low-level routines.
- A part in Gambas that implements the Pop3 protocol, the MIME message 
routines, and the SMTP protocol rewritten in Gambas in the future.

>
> The parsing of the headers is divided into 2 steps. Firts multi-line
> headers are grouped together with a new-line separator so they are
> easy to parse. Then they are organized inside a collection. If a
> header is repeated it's value is replaced by a String[] instance and
> each time a repetition is fount it's appended to this array. I feel
> it is still fast, regardless of it's not-so-optimized
> implementation.
>
> Please leave your comments!

You decided to not use gmime. OK. But so you have to be very careful 
when following the MIME specs, otherwise many of mails will be 
unreadable. I know what I am talking about with gb.net.smtp whose code 
is not mine at the beginning...

As for the interface : MIME is hierarchical, so you have to implement 
different classes with some begin containers MIME parts, and other 
contents MIME parts. You can look at gmime to know what to do, and 
simplify their structure if you can.

Regards,

-- 
Benoît Minisini




More information about the Devel mailing list