Bodystructure? What is he up to?



Nothing to hide here. This is what I'm working on incognito.

BS doesn't stand for bullshit, it stands for BODYSTRUCTURE.

The idea is to make a TnyMimePart and a TnyMsg implementation that
starts with the BODYSTRUCTURE of a message. Using just that information
you can create an entire tree about the message's structure.

Then, with that tree, we'll receive parts as they are first needed.

You will use the TnyStream as-is to stream straight from the server to
your target (a filestream, in case you did "file->save as" or a mime
part viewer in case of something that we can show).

While streaming, Tinymail will cache your part locally too. So that next
time you don't have to stream it from remote.

It goes like this:

 o. Create a new TnyMimePart called TnyCamelBsMimePart
 o. Create a new TnyMsg that inherits TnyCamelBsMimePart called
    TnyCamelBsMsg
 o. Create a new TnyReceiveStrategy that will just receive the
    BODYSTRUCTURE and return a TnyCamelBsMsg as TnyMsg
 o. Use tny_folder_set_msg_receive_strategy to this strategy

This will receive the BODYSTRUCTURE as plain text and store it in a
file. That file is parsed by my recent BODYSTRUCTURE parser into a
struct in C. That struct is fed to the TnyCamelBsMimePart instance which
will work with this. For example to fulfil tny_mime_part_get_parts.

The TnyCamelBsMimePart will now as it gets requests for a part, request
this part from the server. While it receives, it will stream to the
target stream. Meanwhile it will store the received data in its local
cache for future reference.

Implementing what Dape wrote: getting rid of the attachments, will be as
easy as removing files from the filesystem (unlinking them). Restoring
them will be as easy as letting the user request them again.

What will be harder is status information while receiving. This now
happens at the level of the mime part in stead of at the level of the
entire message (the folder's API): each mime part can invoke status
information like "Amount of bytes downloaded". My plan is to duplicate
all relevant TnyMimePart API that needs this type of status information.


The plan is to have this in a Tinymail 2.0, not in a Tinymail 1.0 and
probably not in a Tinymail 1.1 (depends on API and ABI breakage).

This is highly unfinished code, but it should show you the concept.

pvanhoof schtrumpf:~/repos/tinymail/trunk$ cat /tmp/my.bodystructure 
BODYSTRUCTURE (("TEXT" "PLAIN" ("FORMAT" "flowed" "CHARSET" "ISO-8859-15" "REPLY-TYPE" "response") NIL NIL "8BIT" 1464 45 NIL NIL NIL)("APPLICATION" "OCTET-STREAM" ("NAME" "UnicodeEncoding.diff") NIL NIL "QUOTED-PRINTABLE" 17516 NIL ("ATTACHMENT" ("FILENAME" "UnicodeEncoding.diff")) NIL)("TEXT" "PLAIN" ("CHARSET" "us-ascii") NIL NIL "7BIT" 171 4 NIL ("INLINE" NIL) NIL) "MIXED" ("BOUNDARY" "----=_NextPart_000_0006_01C64C15.790DF5A0") NIL NIL)
pvanhoof schtrumpf:~/repos/tinymail/trunk$ cat /tmp/1.1 
E-mail content 1.1
pvanhoof schtrumpf:~/repos/tinymail/trunk$ cat /tmp/1.3
E-mail content 1.3
pvanhoof schtrumpf:~/repos/tinymail/trunk$ 

pvanhoof schtrumpf:~/repos/tinymail/trunk$ svn diff > bodystruct.diff
pvanhoof schtrumpf:~/repos/tinymail/trunk$ tar zcvf my.tar.gz \
	bodystruct.diff libtinymail-camel/tny-camel-bs-msg-receive-strategy.c \
	libtinymail-camel/tny-camel-bs-msg-receive-strategy.h \
	libtinymail-camel/tny-camel-bs-mime-part-priv.h \
	libtinymail-camel/bs libtinymail-camel/tny-camel-bs-mime-part.c \
	libtinymail-camel/tny-camel-bs-mime-part.h \
	libtinymail-camel/tny-camel-bs-msg-priv.h \
	libtinymail-camel/tny-camel-bs-msg.c \
	libtinymail-camel/tny-camel-bs-msg.h

bodystruct.diff
libtinymail-camel/tny-camel-bs-msg-receive-strategy.c
libtinymail-camel/tny-camel-bs-msg-receive-strategy.h
libtinymail-camel/tny-camel-bs-mime-part-priv.h
libtinymail-camel/bs/
libtinymail-camel/bs/bodystruct.h
libtinymail-camel/bs/bodystruct.c
libtinymail-camel/bs/envelope.h
libtinymail-camel/bs/Makefile.in
libtinymail-camel/bs/Makefile.am
libtinymail-camel/bs/Makefile
libtinymail-camel/bs/.deps/
libtinymail-camel/bs/.deps/libbodystruct.Po
libtinymail-camel/bs/.deps/bodystruct.Po
libtinymail-camel/bs/bodystruct.o
libtinymail-camel/bs/libbodystruct.a
libtinymail-camel/tny-camel-bs-mime-part.c
libtinymail-camel/tny-camel-bs-mime-part.h
libtinymail-camel/tny-camel-bs-msg-priv.h
libtinymail-camel/tny-camel-bs-msg.c
libtinymail-camel/tny-camel-bs-msg.h

pvanhoof schtrumpf:~/repos/tinymail/trunk$ svn status
?      bodystruct.diff
?      my.tar.gz
?      libtinymail-camel/tny-camel-bs-msg-receive-strategy.c
?      libtinymail-camel/tny-camel-bs-msg-receive-strategy.h
?      libtinymail-camel/tny-camel-bs-mime-part-priv.h
?      libtinymail-camel/bs
?      libtinymail-camel/tny-camel-bs-mime-part.c
?      libtinymail-camel/tny-camel-bs-mime-part.h
?      libtinymail-camel/tny-camel-bs-msg-priv.h
?      libtinymail-camel/tny-camel-bs-msg.c
?      libtinymail-camel/tny-camel-bs-msg.h
M      libtinymail-camel/Makefile.am
M      tests/c-demo/tny-demoui-summary-view.c
M      configure.ac
pvanhoof schtrumpf:~/repos/tinymail/trunk$ 

-- 
Philip Van Hoof, freelance software developer
home: me at pvanhoof dot be 
gnome: pvanhoof at gnome dot org 
http://pvanhoof.be/blog
http://codeminded.be



Attachment: my.tar.gz
Description: application/compressed-tar



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]