Re: [Dovecot] A X-Mailbox header?

2009-06-23 Thread Timo Sirainen

On Jun 23, 2009, at 10:25 AM, Alessandro Ranellucci wrote:


Nice! The zlib plugin seems a good start.

I guess I'll have to override just storage->v.mailbox_open and then  
mail->v.get_stream. Within get_stream() it seems that the mailbox  
name to put in my X-Mailbox: header is available as _mail->box- 
>name. Am I right?


Sounds right.



Re: [Dovecot] A X-Mailbox header?

2009-06-23 Thread Alessandro Ranellucci

On 22-06-2009 at 20:06, Timo Sirainen wrote:

 >So the somewhat easy to implement possibilities require the X-Mailbox:
 >header to exists always for non-virtual mailboxes too. You 
can either
 >implement code that actually saves it to the maildir files, 
or you can

 >write a plugin that overrides mail_get_stream() and adds the header,
 >similar to how zlib plugin works.

Nice! The zlib plugin seems a good start.

I guess I'll have to override just storage->v.mailbox_open and 
then mail->v.get_stream. Within get_stream() it seems that the 
mailbox name to put in my X-Mailbox: header is available as 
_mail->box->name. Am I right?


Thank you again!

- alessandro.


Re: [Dovecot] A X-Mailbox header?

2009-06-22 Thread Timo Sirainen
On Mon, 2009-06-22 at 18:40 +0200, Alessandro Ranellucci wrote:
> On 22-06-2009 at 17:35, Timo Sirainen wrote:
> 
>  >Hmm. Out of these two possibilities, I think it's easier to just
>  >return a modified message from mail_get_stream(). You could probably
>  >do something similar to what mbox does and use
>  >i_stream_create_header_filter() where you simply return a new
>  >X-Mailbox: header after the headers are sent.
> 
> Thank you, Timo.
> I'll need to get familiar with Dovecot sources.
> 
> That would be implemented as a patch against the virtual plugin?
> Or as a patch against the maildir code?

I'm actually again beginning to wonder what's a good way to implement
this. The main problem is that messages must never change and Dovecot
relies on this. For example messages' virtual sizes are stored in
dovecot.index.cache file. If you change the message, the virtual size
and other similar cached metadata is broken. So simply changing the
message stream in virtual mailboxes won't work, because the cached
metadata would also have to be changed and that makes it much more
difficult.

So the somewhat easy to implement possibilities require the X-Mailbox:
header to exists always for non-virtual mailboxes too. You can either
implement code that actually saves it to the maildir files, or you can
write a plugin that overrides mail_get_stream() and adds the header,
similar to how zlib plugin works.


signature.asc
Description: This is a digitally signed message part


Re: [Dovecot] A X-Mailbox header?

2009-06-22 Thread Alessandro Ranellucci
On 22-06-2009 at 17:35, Timo Sirainen wrote:

 >Hmm. Out of these two possibilities, I think it's easier to just
 >return a modified message from mail_get_stream(). You could probably
 >do something similar to what mbox does and use
 >i_stream_create_header_filter() where you simply return a new
 >X-Mailbox: header after the headers are sent.

Thank you, Timo.
I'll need to get familiar with Dovecot sources.

That would be implemented as a patch against the virtual plugin?
Or as a patch against the maildir code?

- al.


Re: [Dovecot] A X-Mailbox header?

2009-06-22 Thread Timo Sirainen

On Jun 22, 2009, at 6:49 AM, Alessandro Ranellucci wrote:

I was wondering if there's a way to keep the name of the folder  
containing each message while retrieving via POP3. I guess this  
could be done by dynamically adding a header to messages at  
retrieval time. Is there a feature for this or a plugin API?


It's possible to implement as a plugin, but it probably won't be all  
that easy.


Otherwise I was thinking about modifying the messages themselves on  
the server using a script. However, such a script would need to be  
run when a IMAP user moves a message to a folder and I believe  
Dovecot doesn't provide a trigger/hook mechanism.


There are copy/save virtual functions that you can override. For  
example something similar to what antispam plugin does.


I also don't know if modifying stored messages is allowed since it  
could break some caching/hashing mechanism.


Right. You can't modify existing messages. But at the time when a  
message is copied to another mailbox, you can save a slightly  
different version of it. This of course also means that you can't do  
the copying by hard linking a file (assuming you're using maildir).


Hmm. Out of these two possibilities, I think it's easier to just  
return a modified message from mail_get_stream(). You could probably  
do something similar to what mbox does and use  
i_stream_create_header_filter() where you simply return a new X- 
Mailbox: header after the headers are sent.




[Dovecot] A X-Mailbox header?

2009-06-22 Thread Alessandro Ranellucci

Hi all,

I'm waiting for the virtual mailbox feature in order to make a 
single POP3 access to retrieve messages contained in all my 
mailbox folders. This is because I use webmail and other IMAP 
clients but my main workstation uses a POP3-only client.


I was wondering if there's a way to keep the name of the folder 
containing each message while retrieving via POP3. I guess this 
could be done by dynamically adding a header to messages at 
retrieval time. Is there a feature for this or a plugin API?


Otherwise I was thinking about modifying the messages themselves 
on the server using a script. However, such a script would need 
to be run when a IMAP user moves a message to a folder and I 
believe Dovecot doesn't provide a trigger/hook mechanism. I also 
don't know if modifying stored messages is allowed since it 
could break some caching/hashing mechanism.


Do you have any idea for this?

Thanks in advance and thanks to Timo for the great work!

- alessandro.