Hi Jens,
I'm CC-ing the trojita mailing list, so that others can benefit from our
discussion. I hope you don't mind. You might want to subscribe there,
it's a pretty low volume list. To subscribe, just send a mail to
[email protected] .

> I would like to
>     1. add a dialog to Trojita, which pops up and gets focus if a new
> mail arrives.

This one is a rather missing gap in Trojita's features. Right now, there
is no way to tell that a "new mail" arrived. The IMAP model emits
rowsInserted() (as any other model) upon adding new items, but it
signals additions on a (rather low) QAbstractItemModel level, not on the
logical level of "new mail".

Ie. when user has not configured any persistent cache (default settings)
and you open a mailbox with, say, 1234 messages, you get notified that
the Trojita's idea about a mailbox state has changed from the initial
state to 1234 messages. Then, when a new message arrives, you'll be
notified that there's been one addition at the very end of the mailbox.

Your best bet at this time is to listen to Imap::Mailbox::Model's
messageCountPossiblyChanged(). Tehn you can use various item roles
(RoleTotalMessageCount, RoleUnreadMessageCount and
RoleRecentMessageCount) to retrieve the numbers you want to use, and act
if they changed since the last time.

I'll add some more high-level code later on.

In addition to that, there's also some code I wrote when I was
contracted to use Trojita's IMAP code to write a batch downloader for
OpenMFG DBA xTuple, Llc -- see src/XtConnect if you're after creating
something for e-mail batch processing.

>     2. I would like to make Trojita check mails every x secounds.

This is already implemented. Trojita always keeps the last open mailbox
open and synchronizes it on the fly. If the remote IMAP server supports
IDLE, you'll be notified immediately. If IDLE is not supported, Trojita
has to resort to periodic polling. By default, this polling happens
every two minutes, and it can be configured by setting the
Imap::Mailbox::Model's QObject's property "trojita-imap-noop-period" (in
milliseconds).

Right now, Trojita only uses one connection to the IMAP server and does
not implement any periodic checks for other mailboxes than the currently
selected one. I'd like to change this in 0.4, there's a bugreport for it
[1].

[1] https://projects.flaska.net/issues/86

Cheers,
Jan

-- 
Trojita, a fast e-mail client -- http://trojita.flaska.net/

Attachment: signature.asc
Description: OpenPGP digital signature

Reply via email to