Good morning,
Alexandru asked for examples of how GroupDAV[1], vCard[2] and vCalendar[3]
relate to email. The relation is, that vCard and vCalendar both are based on
the MIME format explained in rfc2425 and rfc4234.
The syntax of a contentline in a vCard is:
contentline := [group "."] name *(";" param) ":" value CRLF
or as an example:
TEL;type=WORK;type=pref:+1 617 555 1212
Contentlines can also be folded with continuation lines marked by a leading
whitespace:
DESCRIPTION:This is a long descrip
tion that exists o
n a long line.
So the first steps to parse a vCard are:
1. unfold lines
2. breakup contentlines in their components
I looked at ezcMail to see whether I can reuse classes to do this two tasks.
But even after a couple of hours studying the code I'm not sure about it.
(This is no critique on the code. The whole MIME stuff is so complicate that
the code handling it needs to be complex, too.)
I made a quick prototype of a custom MIME parser which is composed of the
following classes:
SimpleLineIterator
------------------
Returns a textline delimited by CRNL on every iteration. I did not use
explode( CRNL, $text ) to reduce memory usage and to keep the classes usable
for streams.
UnfoldIterator
--------------
Iterates over the SimpleLineIterator and looks one line ahead. If the
following line starts with a whitespace, it is added to the current line and
the lookahead repeats.
ContentLine
-----------
The ContentLine class is a struct holding all components of a MIME
contentline: group, name, array of parameters, value. It has a static create
method accepting a plain contentline string and returning self. The main part
is done by this regexp:
'/^
(?:([a-zA-Z-\d]+)\.)? # group: ALPHA | DIGIT | "-"
([a-zA-Z-_]*) # name: x-name | iana-token
(;[\w-_=;]+)* # parameters: *(";" param)
:\s?
(.*)/x', # value: *VALUE-CHAR | valuespec
Now with the ContentLine class on hand it is not very complicate anymore, to
parse a vCard or a vCalendar or any other MIME type.
The connection between GroupDAV and email is, that GroupDAV communicates with
vCard and vCalendar items. So as soon as I can read and write these formats,
I can build a datastore for my PIM data on top of eZComponents with very
little effort.
Do you think it would be better to reuse classes from ezcMail or to build a
separate MIME parser/builder for arbitrary types? It seems reasonable to me
to have a mail component which is optimized to handle mail very fast.
Handling vCards on the other hand is not time critical, but should be easily
extendable.
[1] http://www.groupdav.org/
[2] rfc2426
[3] rfc2445
Cheers,
--
Thomas Koch, Software Developer
Young Media Concepts GmbH
Sonnenstr. 4
CH-8280 Kreuzlingen
Switzerland
Tel +41 (0)71 / 508 24 86
Fax +41 (0)71 / 560 53 89
Mobile +49 (0)170 / 753 89 16
Web www.ymc.ch
--
Components mailing list
[email protected]
http://lists.ez.no/mailman/listinfo/components