Subject: New driver implementation

From: "Jacques Exelrud" <[email-masked]>
Date: Thu, 14 Nov 2002 14:02:07 -0200

I'm developing a new driver to connect to an internal database where I work.

	I can't easily keep track of what the user have seen or not so every time he selects a folder I inform that all messages are new. Is there a better way to handle that ?

	Also this new driver will get the message body from one source and the possible attachments from another. I'm having trouble building the envelope to describe them.
	I implemented the structure entry from the DRIVER table but without full success. 

		I'm unable to name the attachments.
		If exists at least one attachment the body is not shown (it is not even requested)

	Any help would be greatly appreciated.

	Thanks in advance,
	Jacques

-- 
------------------------------------------------------------------
 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: Thu, 14 Nov 2002 08:50:07 -0800 (PST)

On Thu, 14 Nov 2002 14:02:07 -0200, Jacques Exelrud wrote:
> I can't easily keep track of what the user have seen or not so every
> time he selects a folder I inform that all messages are new. Is there a
> better way to handle that ?

You should reserve space for flags in your database, and allow the IMAP
session to write the flags via the flags and/or flagmsg driver methods.

> Also this new driver will get the message body from one source and the
> possible attachments from another. I'm having trouble building the envelope
> to describe them.

There are two ways to do this: the easy way and the hard way.

The easy way is to store, in your database, an RFC2822 representation of the
message header and message body.  Then, implement the header and text methods
and return the respective strings.  Let c-client work out the details of how
to generate an ENVELOPE and BODY structure, and how to do partial fetching.

The hard way is to have the database have the message in various pieces
without an RFC2822 representation.  If you do this, you must either store, or
be able to generate on demand:
 . a complete representation of the ENVELOPE and BODY structures, including
    exact size counts
 . all possible BODY[...] texts including arbitrary substrings, and return the
    exact texts
In effect, you must implement all possible forms of IMAP fetch as queries in
your database, and c-client will not help you at all.

Your message indicates that you are doing it the hard way, and as you have
discovered, the hard way is very difficult.  I do not know of anyone who has
succeeded in doing it the hard way.

Microsoft Exchange tried to do IMAP the hard way, and had many problems with
getting it to work according to specification.  Eventually, they gave up and
did things the easy way, and now Exchange works properly.  Of course, since
they don't use c-client, they had to duplicate what c-client does.  But it was
still much easier than doing it the hard way.

If Microsoft, with all its resources, found the hard way to be too difficult,
you should consider whether you really want to try to do it the hard way.