Subject: Mailbox driver functions

From: Jan Nilsson <[email-masked]>
Date: 16 Aug 00 21:28:53 MET DST

Hi all,

I'm working on a UW IMAPD mailbox driver for my very special needs
(from the IMAPD:s point of view you could see it as
the message header being stored in one db, the message text in
another and possible attachments in a third. All across network).

I've taken the unix driver (and learned alot from it) and changed it
gradually to suit my environment.
I have had some success in implementing some of the driver functions,
but now I'm a bit stuck.

I need to implement the "structure" and the "msgdata" driver
functions to make database access efficient (other suggestions ?),
but I'm not sure I know everything these functions should do.

In the unix driver (and all the others), the "structure" and
"msgdata" functions are not implemented
(as I understand it, the "text" function is used instead),
so there is no code to learn from.

Below is my guessing (and also some Q:s) of what these functions
should do, please correct my assumptions and tell me what's missing.

The "structure" function
------------------------
This function shall parse the structure of a message (duh) and:
 - create a new ENVELOPE (if one doesn't exists already) and fill it
   with info and store pointer to it in elt->private.msg.env
 - create a new BODY (if one doesn't exists already) and fill it
   with info and store pointer to it in elt->private.msg.body
   (what info at minimum do I need to fill it with ??)
 - If more than one bodypart, create additional linked BODY:s in PART:s
   storing pointer of the first in elt->private.msg.body->nested.body

I assume that I don't have to fill any body->contents with data. 
Do I need to fill BODY.size.lines and BODY.size.bytes with
data in this function ?
Do I need to do anything with :
      elt->private.msg.full
      elt->private.msg.lines
      elt->private.msg.header
      elt->private.msg.text

The "msgdata" function
------------------------
This function shall return the data for a given section of a message.
If 0=<first<last it's a partial fetch of that section.
 - Fill the body->contents (for the given section) with data.

Do need to do anything with:
      elt->private.msg.full
      elt->private.msg.lines
      elt->private.msg.header
      elt->private.msg.text

If I allocate mem for holding the data of a section whenever this
function is called it could really eat a lot of mem if fetching
a large attachment or if many parts have been fetched and are kept
in the cache.
I need to study the code more though, as I understand there are
ways to attack this problem (mailgets function? cache mgmt? feel
free to give me a hint ;) )

Anyone has some example code or can point me to some info
to help me with the above issues ?

Thanks!
Jan

____________________________________________________________________
Get free email and a permanent address at http://www.netaddress.com/?N=1
-- 
------------------------------------------------------------------
 For information about this mailing list, and its archives, see: 
 http://www.washington.edu/imap/c-client-list.html
------------------------------------------------------------------

---

From: Mark Crispin <[email-masked]>
Date: Wed, 16 Aug 2000 14:34:40 -0700 (PDT)

To best understand what the structure and msgdata methods do, look at the IMAP
driver which implements these methords.

All the "private" structure members are for c-client's internal convenience.
Applications do not reference them (and are forbidden from referencing them).
You do not need to use any of them.  If you do use them, then you need to use
them in a way that matches mail.c's caching expectations.

You *MUST* fill all ENVELOPE and BODY structures with the complete set of
information that comes from IMAP.  In other words, you must fill in sizes such
as body->size.lines and body->size.bytes; these are not optional.

The choice of whether to cache message texts in memory or not is up to you.
However, if you use the msgdata interface, you will have to load the
appropriate SIZEDTEXT structure in c-client's cache with the string and its
size.  Take a look at imap_cache() to see what needs to be done to register a
text in the cache.

The application can tell you to cache something else, if it arms a mailgets_t
callback routine.  Take a look at imap_parse_string() to see how this works.