History log of /haiku/src/add-ons/mail_daemon/inbound_protocols/imap/IMAPProtocol.cpp
Revision Date Author Comments
(<<< Hide modified files)
(Show modified files >>>)
# dd3f595b 12-Mar-2023 Zach Dykstra <dykstra.zachary@gmail.com>

mail: only copy attributes for new IMAP folders

When mail_daemon associates a subscribed IMAP folder with a local
folder, ~/config/settings/Tracker/DefaultQueryTemplates/text_x-email
attributes are duplicated to the folder. Any customizations (column
layout, window size / location, etc) are overwritten by the values set
for text_x-email. The text_x-email template folder was originally meant
to be used by the 'New E-mail' query. In particular, the columns that
might be set for the query view aren't directly useful for an IMAP
folder - Account is useful for the query view, but not for an IMAP
folder, Status is not useful for the query view, but useful for an IMAP
folder.

This behavior is now modified such that attributes are only copied the
first time an IMAP folder is created. Subsequent launches of mail_daemon
will not overwrite per-folder customizations.

Fixes #18297

Change-Id: Iacdc78403681d5546668f28f7f0e34d1a57fd410
Reviewed-on: https://review.haiku-os.org/c/haiku/+/6202
Tested-by: Automation <automation@haiku-os.org>
Reviewed-by: waddlesplash <waddlesplash@gmail.com>


# 4f1e67e1 10-Mar-2023 Zach Dykstra <dykstra.zachary@gmail.com>

mail: fix crash when associating IMAPFolder

_CreateFolder returns NULL when it's unable to create a folder on the
local filesystem to represent an IMAP folder. This can happen when a
file has the same name as an IMAP folder that has been subscribed to on
the remote server.

Handle this condition and do not try to add the folder to a connection worker.

Change-Id: I197d577fabe45360ffa9ce4ac07da34652e78fdd
Reviewed-on: https://review.haiku-os.org/c/haiku/+/6186
Reviewed-by: waddlesplash <waddlesplash@gmail.com>


# ed78fbfc 12-Jun-2020 Murai Takashi <tmurai01@gmail.com>

inbound_protocols/imap: Fix PVS V773

Fix IMAPProtocol::_CreateFolder() was exited
without releasing 'folder' pointer.

Change-Id: I80249694b7a977a220cfb0853b169bae83129f76
Reviewed-on: https://review.haiku-os.org/c/haiku/+/2908
Reviewed-by: waddlesplash <waddlesplash@gmail.com>


# 6fa27973 08-Dec-2018 Peter Kosyh <p.kosyh@gmail.com>

IMAP: sync fixes

This patch should fix:

- deadlocks while manual syncing/shutdown;
- crashes while manual syncing/shutdown.

Change-Id: I0962ff5580c19cbf740d002b6f62681ed5f558ab
Reviewed-on: https://review.haiku-os.org/758
Reviewed-by: Stephan Aßmus <superstippi@gmx.de>


# a6a7e73f 18-Nov-2018 Peter Kosyh <p.kosyh@gmail.com>

mail: revert ~IMAPProtocol

Waiting of worker threads in IMAPProtocol destructor introducred new deadlocks.

For example: fWorkerLock grabbed in destructor leads to deadlock with
CheckSubscribedFoldersCommand (which grabs this lock with flock grabbed).

So, currently it should be reverted.

Change-Id: Ibc4b4f85300352e045d4ce72deb804e0e613f25c
Reviewed-on: https://review.haiku-os.org/714
Reviewed-by: waddlesplash <waddlesplash@gmail.com>


# 1f41c99f 11-Nov-2018 Peter Kosyh <p.kosyh@gmail.com>

mail: IMAP inbound protocol destructor fix

This should fix crashes of mailer_daemon in IMAP workers.
This patch makes IMAPConnection destructor wait for all working threads to finish.
Also, do not call _Connect for QuitCommand (it speedups shutdown procedure).

Change-Id: Idffcc00d3459a96a85a8a073a343bcf4cd4984be
Reviewed-on: https://review.haiku-os.org/686
Reviewed-by: waddlesplash <waddlesplash@gmail.com>


# de4b1ded 20-Jan-2016 Axel Dörfler <axeld@pinc-software.de>

BMailProtocol: Removed delete/append methods.

* The mail system is file based which makes these methods pretty much
superfluous.

# 618cc43b 14-Jan-2016 Axel Dörfler <axeld@pinc-software.de>

IMAP: New folders will now adopt default mail attributes.

* Added a function CopyMailFolderAttributes() that copies the attribute
layout from the text/x-email default query folder.
* This using the new CopyAttributes() method in libshared that is pretty
much a copy of a similar method from copyattr. However, I did not
replace the latter, as that one allows for more fine grained error
reporting (and attribute filtering).
* Closes ticket #3498.

# 81805393 04-Jan-2016 Axel Dörfler <axeld@pinc-software.de>

IMAP: setting flags, and body fetching works now.

* The direct methods in BMailProtocol now forward the request to the
looper; it's no longer the mail_daemon's responsibility to know
anything about that protocol.
* It's in desperate need of refactoring, but it doesn't hurt to add
it to the repository as is.

# 29871039 21-Dec-2015 Axel Dörfler <axeld@pinc-software.de>

IMAP: Use BStringList instead of STL vector.

# 62eec600 21-Nov-2015 Axel Dörfler <axeld@pinc-software.de>

SMTP works again.

* The message to send the mails never made it to the add-on looper.
* Mail protocol threads now have names.
* Added a "public" BOutboundMailProtocol::SendMessages() call that sends
itself a message (even the correct one this time).

# 4fe2002b 08-Jan-2015 Axel Dörfler <axeld@pinc-software.de>

IMAP: fixed GCC4 build.

# d33e4744 03-Jul-2013 Axel Dörfler <axeld@pinc-software.de>

IMAP: downloading mails is now working.

* Changed the way the attributes are written to make sure that everything
that can be written once is in fact written just once.
* The rename code in BMailProtocol::_ProcessFetchedHeader() was broken,
and caused the hang of the last commit.

# 549949b2 26-Jun-2013 Axel Dörfler <axeld@pinc-software.de>

Mail Kit: Changed how filter changes work.

* BMailFilter::HeaderFetched() now only alters the entry_ref, and returns
B_MOVE_MAIL_ACTION to move a mail.
* Instead of potentially moving the file around several times, the
BMailProtocol now takes care of carrying out the filter action just once,
including trying to make the file name unique.
* This also allows the IMAP add-on to know the final location of the mail,
and thus downloading a message actually works.
* However, with my test inbox, it currently hangs, and a current Debugger does
not work on my older system -- I guess I need to update.
* Replaced the duplicated space mechanism within the "HaikuMailFormatFilter"
that is substantially faster, and handles all whitespace, not just spaces.
It will also replace tabs with spaces.

# 1052525d 22-May-2013 Axel Dörfler <axeld@pinc-software.de>

IMAP: work in progress of downloading the mail body.

* Most things are in place now, we just try to download the body to the
wrong file, as the final location is currently unknown.
* Added local only kPartialMessage flag for mails, but it's not being
used yet.

# 4b2c5571 13-May-2013 Axel Dörfler <axeld@pinc-software.de>

IMAP: sync when requested.

# 28ee6c28 25-Apr-2013 Axel Dörfler <axeld@pinc-software.de>

IMAP: Use useful default without destination.

* We now use the account name as destination directory.
* Turns out that an empty string is written as destination which worked
around the GetString() solution.

# eba458b9 24-Apr-2013 Axel Dörfler <axeld@pinc-software.de>

imap: Fetching headers is now working.

* No state is stored yet, though, so that all messages will be downloaded
over and over again.

# 229c7773 14-Apr-2013 Axel Dörfler <axeld@pinc-software.de>

imap: Testing for new messages is now working.

* There is now a CheckSubscribedFoldersCommand that is issued on the main
connection that triggers everything.
* The new CheckMailboxesCommand divides the new mail check into several
portions, and requeues itself until the next step, ie. the
FetchHeadersCommand.
* The headers of the new mails are downloaded, but nothing is done with
them yet.
* The actual check for the new mails doesn't scale that well yet, not sure
how to properly do this without having to rely on the mail indices. Might
be sensible to solve this via some simple heuristic.

# 7993ddfa 10-Apr-2013 Axel Dörfler <axeld@pinc-software.de>

imap: Fleshed out command processing.

* Still doesn't do anything useful, though.

# a4bdd26d 05-Apr-2013 Axel Dörfler <axeld@pinc-software.de>

imap: Work in progress of connection setup.

* SelectCommand now correctly encodes the mailbox name again.
* Hierarchy separators from the LIST/LSUB commands are now properly parsed,
and taken into account.
* Folders in the file system are now created for mailboxes on the server,
supporting hierarchical mailbox names.
* A connection worker now has an IMAPFolder that handles the local side of the
mailbox, and an IMAPMailbox that handles the server side.
* Connection workers are now created/deleted, and setup correctly. They will
now also wait in case they don't have a mailbox until they get some.

# adbe8fc9 24-Mar-2013 Axel Dörfler <axeld@pinc-software.de>

IMAP: The connection workers are now started.

* On SyncMessages(), the main connection worker is started if it is not already
running (it may only run already in idle mode).
* This will then list the subscribed folders, and create as many more connection
workers as allowed and make sense.
* Finally, it will distribute the folders to the workers which don't do anything
further yet.

# 186c96d5 18-Jan-2013 Axel Dörfler <axeld@pinc-software.de>

IMAP: Early work in progress of main protocol class.

# de4b1ded 20-Jan-2016 Axel Dörfler <axeld@pinc-software.de>

BMailProtocol: Removed delete/append methods.

* The mail system is file based which makes these methods pretty much
superfluous.


# 618cc43b 14-Jan-2016 Axel Dörfler <axeld@pinc-software.de>

IMAP: New folders will now adopt default mail attributes.

* Added a function CopyMailFolderAttributes() that copies the attribute
layout from the text/x-email default query folder.
* This using the new CopyAttributes() method in libshared that is pretty
much a copy of a similar method from copyattr. However, I did not
replace the latter, as that one allows for more fine grained error
reporting (and attribute filtering).
* Closes ticket #3498.


# 81805393 04-Jan-2016 Axel Dörfler <axeld@pinc-software.de>

IMAP: setting flags, and body fetching works now.

* The direct methods in BMailProtocol now forward the request to the
looper; it's no longer the mail_daemon's responsibility to know
anything about that protocol.
* It's in desperate need of refactoring, but it doesn't hurt to add
it to the repository as is.


# 29871039 21-Dec-2015 Axel Dörfler <axeld@pinc-software.de>

IMAP: Use BStringList instead of STL vector.


# 62eec600 21-Nov-2015 Axel Dörfler <axeld@pinc-software.de>

SMTP works again.

* The message to send the mails never made it to the add-on looper.
* Mail protocol threads now have names.
* Added a "public" BOutboundMailProtocol::SendMessages() call that sends
itself a message (even the correct one this time).


# 4fe2002b 08-Jan-2015 Axel Dörfler <axeld@pinc-software.de>

IMAP: fixed GCC4 build.


# d33e4744 03-Jul-2013 Axel Dörfler <axeld@pinc-software.de>

IMAP: downloading mails is now working.

* Changed the way the attributes are written to make sure that everything
that can be written once is in fact written just once.
* The rename code in BMailProtocol::_ProcessFetchedHeader() was broken,
and caused the hang of the last commit.


# 549949b2 26-Jun-2013 Axel Dörfler <axeld@pinc-software.de>

Mail Kit: Changed how filter changes work.

* BMailFilter::HeaderFetched() now only alters the entry_ref, and returns
B_MOVE_MAIL_ACTION to move a mail.
* Instead of potentially moving the file around several times, the
BMailProtocol now takes care of carrying out the filter action just once,
including trying to make the file name unique.
* This also allows the IMAP add-on to know the final location of the mail,
and thus downloading a message actually works.
* However, with my test inbox, it currently hangs, and a current Debugger does
not work on my older system -- I guess I need to update.
* Replaced the duplicated space mechanism within the "HaikuMailFormatFilter"
that is substantially faster, and handles all whitespace, not just spaces.
It will also replace tabs with spaces.


# 1052525d 22-May-2013 Axel Dörfler <axeld@pinc-software.de>

IMAP: work in progress of downloading the mail body.

* Most things are in place now, we just try to download the body to the
wrong file, as the final location is currently unknown.
* Added local only kPartialMessage flag for mails, but it's not being
used yet.


# 4b2c5571 13-May-2013 Axel Dörfler <axeld@pinc-software.de>

IMAP: sync when requested.


# 28ee6c28 25-Apr-2013 Axel Dörfler <axeld@pinc-software.de>

IMAP: Use useful default without destination.

* We now use the account name as destination directory.
* Turns out that an empty string is written as destination which worked
around the GetString() solution.


# eba458b9 24-Apr-2013 Axel Dörfler <axeld@pinc-software.de>

imap: Fetching headers is now working.

* No state is stored yet, though, so that all messages will be downloaded
over and over again.


# 229c7773 14-Apr-2013 Axel Dörfler <axeld@pinc-software.de>

imap: Testing for new messages is now working.

* There is now a CheckSubscribedFoldersCommand that is issued on the main
connection that triggers everything.
* The new CheckMailboxesCommand divides the new mail check into several
portions, and requeues itself until the next step, ie. the
FetchHeadersCommand.
* The headers of the new mails are downloaded, but nothing is done with
them yet.
* The actual check for the new mails doesn't scale that well yet, not sure
how to properly do this without having to rely on the mail indices. Might
be sensible to solve this via some simple heuristic.


# 7993ddfa 10-Apr-2013 Axel Dörfler <axeld@pinc-software.de>

imap: Fleshed out command processing.

* Still doesn't do anything useful, though.


# a4bdd26d 05-Apr-2013 Axel Dörfler <axeld@pinc-software.de>

imap: Work in progress of connection setup.

* SelectCommand now correctly encodes the mailbox name again.
* Hierarchy separators from the LIST/LSUB commands are now properly parsed,
and taken into account.
* Folders in the file system are now created for mailboxes on the server,
supporting hierarchical mailbox names.
* A connection worker now has an IMAPFolder that handles the local side of the
mailbox, and an IMAPMailbox that handles the server side.
* Connection workers are now created/deleted, and setup correctly. They will
now also wait in case they don't have a mailbox until they get some.


# adbe8fc9 24-Mar-2013 Axel Dörfler <axeld@pinc-software.de>

IMAP: The connection workers are now started.

* On SyncMessages(), the main connection worker is started if it is not already
running (it may only run already in idle mode).
* This will then list the subscribed folders, and create as many more connection
workers as allowed and make sense.
* Finally, it will distribute the folders to the workers which don't do anything
further yet.


# 186c96d5 18-Jan-2013 Axel Dörfler <axeld@pinc-software.de>

IMAP: Early work in progress of main protocol class.


# 4fe2002b472457c74c6ba59f4ceec5606df6a690 08-Jan-2015 Axel Dörfler <axeld@pinc-software.de>

IMAP: fixed GCC4 build.


# d33e4744df1542a1350f55c25ce7b691560d7345 03-Jul-2013 Axel Dörfler <axeld@pinc-software.de>

IMAP: downloading mails is now working.

* Changed the way the attributes are written to make sure that everything
that can be written once is in fact written just once.
* The rename code in BMailProtocol::_ProcessFetchedHeader() was broken,
and caused the hang of the last commit.


# 549949b26f4df07ba280792c18a515553f489388 26-Jun-2013 Axel Dörfler <axeld@pinc-software.de>

Mail Kit: Changed how filter changes work.

* BMailFilter::HeaderFetched() now only alters the entry_ref, and returns
B_MOVE_MAIL_ACTION to move a mail.
* Instead of potentially moving the file around several times, the
BMailProtocol now takes care of carrying out the filter action just once,
including trying to make the file name unique.
* This also allows the IMAP add-on to know the final location of the mail,
and thus downloading a message actually works.
* However, with my test inbox, it currently hangs, and a current Debugger does
not work on my older system -- I guess I need to update.
* Replaced the duplicated space mechanism within the "HaikuMailFormatFilter"
that is substantially faster, and handles all whitespace, not just spaces.
It will also replace tabs with spaces.


# 1052525dc5cfda3563a36ad82b4a900d7beb5221 22-May-2013 Axel Dörfler <axeld@pinc-software.de>

IMAP: work in progress of downloading the mail body.

* Most things are in place now, we just try to download the body to the
wrong file, as the final location is currently unknown.
* Added local only kPartialMessage flag for mails, but it's not being
used yet.


# 4b2c5571c05d4f7edb62cb093ce8374d57778498 13-May-2013 Axel Dörfler <axeld@pinc-software.de>

IMAP: sync when requested.


# 28ee6c28394b54048a391dfd1b398aad22b47a38 25-Apr-2013 Axel Dörfler <axeld@pinc-software.de>

IMAP: Use useful default without destination.

* We now use the account name as destination directory.
* Turns out that an empty string is written as destination which worked
around the GetString() solution.


# eba458b9407056235aeb184a038e202b2d7bfe5e 24-Apr-2013 Axel Dörfler <axeld@pinc-software.de>

imap: Fetching headers is now working.

* No state is stored yet, though, so that all messages will be downloaded
over and over again.


# 229c7773234389164b47efc09f348b248b8caf47 14-Apr-2013 Axel Dörfler <axeld@pinc-software.de>

imap: Testing for new messages is now working.

* There is now a CheckSubscribedFoldersCommand that is issued on the main
connection that triggers everything.
* The new CheckMailboxesCommand divides the new mail check into several
portions, and requeues itself until the next step, ie. the
FetchHeadersCommand.
* The headers of the new mails are downloaded, but nothing is done with
them yet.
* The actual check for the new mails doesn't scale that well yet, not sure
how to properly do this without having to rely on the mail indices. Might
be sensible to solve this via some simple heuristic.


# 7993ddfabaa0069192062289b4fb18c0034cdf76 10-Apr-2013 Axel Dörfler <axeld@pinc-software.de>

imap: Fleshed out command processing.

* Still doesn't do anything useful, though.


# a4bdd26d61967231469220573c4b5ee09e29dd49 05-Apr-2013 Axel Dörfler <axeld@pinc-software.de>

imap: Work in progress of connection setup.

* SelectCommand now correctly encodes the mailbox name again.
* Hierarchy separators from the LIST/LSUB commands are now properly parsed,
and taken into account.
* Folders in the file system are now created for mailboxes on the server,
supporting hierarchical mailbox names.
* A connection worker now has an IMAPFolder that handles the local side of the
mailbox, and an IMAPMailbox that handles the server side.
* Connection workers are now created/deleted, and setup correctly. They will
now also wait in case they don't have a mailbox until they get some.


# adbe8fc944d2568ba87d7603e921115830ef1416 24-Mar-2013 Axel Dörfler <axeld@pinc-software.de>

IMAP: The connection workers are now started.

* On SyncMessages(), the main connection worker is started if it is not already
running (it may only run already in idle mode).
* This will then list the subscribed folders, and create as many more connection
workers as allowed and make sense.
* Finally, it will distribute the folders to the workers which don't do anything
further yet.


# 186c96d50c1df03eb711dce3d1d22ebae88c18ae 18-Jan-2013 Axel Dörfler <axeld@pinc-software.de>

IMAP: Early work in progress of main protocol class.