Open Bug 2057063 Opened 4 months ago Updated 11 days ago

Prefactor nsMsgOfflineImapOperation

Categories

(MailNews Core :: Database, task)

task

Tracking

(Not tracked)

ASSIGNED
162 Branch

People

(Reporter: benc, Assigned: benc)

References

(Blocks 1 open bug)

Details

(Keywords: leave-open)

Attachments

(17 external files)

Offline IMAP operations (which - of course - are also used for some online operations ;- ) have a whole lot of quirks that deserve to be sorted out.

In particular, they have no concept of tracking IMAP UIDs separate to nsMsgKey which needs to be done for Bug 1806770.

But while we're here, it looks like it might be worthwhile to sort out some of the other oddities:

  • nsMsgOfflineImapOperation (the only implementation) is explicitly tied to a Mork database row. This is a showstopper for getting IMAP working with Panorama (the globaldb work).
  • Offline operations are indexed by nsMsgKey. It's not clear if that was just a convenient unique ID or if it's actually also used to look up messages in the database (not always possible - for example, with offline deletes the local message is already gone). In any case, it definitely seems like offline operations should have their own database-assigned unique ID. Another showstopper for Panorama.
  • There's an nsIMsgOfflineImapOperation interface which handles all the different operation types, but it's not clear which attributes are used for which operations, or how to set up an offline operation (other than looking at what calling code currently does).
  • Creation and fetching is merged into a single function, MailDatabase::GetOfflineOpForKey(), which may return a blank, uninitialised object, leaving it up to the caller to distinguish and deal with.
  • The operation types are bitflags rather than simple enumerations - nsMsgOfflineImapOperation::SetOperation(nsOfflineImapOperationType aOperation) performs a bitwise OR to merge aOperation with whatever other value might be set.
  • The valid combination of operation bits is very murky and ill-defined.

Not quite sure of the shape of this yet.
My primary aims are to first support non-nsMsgKey UIDs properly and secondly to get to a point where it'll be possible to provide a Panorama implementation.
I think attempting a bit of refactoring is going to be the best way to actually understand this code, so that's where I'm going to start.

Ahh. And nsImapOfflineDownloader inherits from nsImapOfflineSync.
There's not a lot of commonality there, and it makes nsImapOfflineSync much harder to refactor... maybe should it be split out into a simpler class of it's own rather than using inheritance... hmm...

See Also: → 1285101
Depends on: 2059345
Keywords: leave-open
Target Milestone: --- → 155 Branch

Pushed by benc@thunderbird.net:
https://hg.mozilla.org/comm-central/rev/136c57adf76a
Remove unused nsIMsgOfflineImapOperation.numberOfCopies. r=tobyp

See Also: → 2060778
Attachment #9625086 - Attachment description: Bug 2057063 - Tighten up IMAP offline operation ordering. r=#thunderbird-back-end-reviewers → Bug 2057063 - Tidy up IMAP offline operation dispatching. r=#thunderbird-back-end-reviewers

Pushed by benc@thunderbird.net:
https://hg.mozilla.org/comm-central/rev/6402f6b63663
Remove dead nsMsgFolderFlags::CreatedOffline flag and associated offline-sync code. r=tobyp
https://hg.mozilla.org/comm-central/rev/d54d7419f2a3
Remove redundant nsIMsgImapMailFolder.liteSelect(). r=tobyp
https://hg.mozilla.org/comm-central/rev/21105d09876a
Tidy up IMAP offline operation dispatching. r=tobyp

See Also: → 2065077

We need to refer to UIDs from various non-imap places, so may as well
define it in base rather than pretending we can hide it down in IMAP.

Attachment #9629322 - Attachment description: WIP: Bug 2057063 - Add .srcUid field on nsIMsgOfflineImapOperation and remember UID for Move → Bug 2057063 - Add .srcUid field on nsIMsgOfflineImapOperation and remember UID for Move. r=#thunderbird-back-end-reviewers

Pushed by geoff@darktrojan.net:
https://hg.mozilla.org/comm-central/rev/cce37c6cfa7c
Move the definition of ImapUid type into base. r=mkmelin

The main aim here is to just try and note most of the numerous quirks
of nsIMsgOfflineImapOperation, in order to make it easier to replace
with something simpler and clearer and more robust.

Attachment #9629322 - Attachment description: Bug 2057063 - Add .srcUid field on nsIMsgOfflineImapOperation and remember UID for Move. r=#thunderbird-back-end-reviewers → WIP: Bug 2057063 - Add .srcUid field on nsIMsgOfflineImapOperation for use with copy/move operations. r=#thunderbird-back-end-reviewers
Attachment #9629322 - Attachment description: WIP: Bug 2057063 - Add .srcUid field on nsIMsgOfflineImapOperation for use with copy/move operations. r=#thunderbird-back-end-reviewers → Bug 2057063 - Add UID support to nsIMsgOfflineImapOperation for copy/move operations. r=#thunderbird-back-end-reviewers

Pushed by brendan@thunderbird.net:
https://hg.mozilla.org/comm-central/rev/19413942c04a
Add {fmt} support to nsIMsgOfflineImapOperation to ease debugging and logging. r=mkmelin

Doesn't apply. Please rebase

Rebased now. Take two!

Pushed by edicharry@thunderbird.net:
https://hg.mozilla.org/comm-central/rev/fedb41d454cd
Comment only changes. Document nsIMsgOfflineImapOperation interface. r=mkmelin
https://hg.mozilla.org/comm-central/rev/7afa35ebd6d9
Add UID support to nsIMsgOfflineImapOperation for copy/move operations. r=mkmelin

Blocks: 2089447
See Also: → 2089877

can you please rebase the whole stack?

Thanks - rebased now, so should be good to go!

Target Milestone: 155 Branch → 162 Branch

Pushed by geoff@darktrojan.net:
https://hg.mozilla.org/comm-central/rev/97120e314f40
Make nsIMsgOfflineImapOperation.sourceFolderUri read-only. r=thunderbird-back-end-reviewers,babolivier
https://hg.mozilla.org/comm-central/rev/f4fc9643862e
Add setter method for nsIMsgOfflineImapOperation kDeleteAllMsgs. r=thunderbird-back-end-reviewers,babolivier
https://hg.mozilla.org/comm-central/rev/e1dd5185ec32
Add setter methods for nsIMsgOfflineImapOperation kMsgMoved and kMsgCopy. r=thunderbird-back-end-reviewers,babolivier
https://hg.mozilla.org/comm-central/rev/157780fe5bb4
Add setter methods for nsIMsgOfflineImapOperation kAppendDraft. r=thunderbird-back-end-reviewers,babolivier
https://hg.mozilla.org/comm-central/rev/671bc17ccf51
Tidy up nsIMsgOfflineImapOperation methods for setting up kAddKeywords and kRemoveKeywords operations. r=thunderbird-back-end-reviewers,babolivier
https://hg.mozilla.org/comm-central/rev/0f3568ddf825
Fix mixups between nsIMsgOfflineImapOperation operation and imap flags. r=thunderbird-back-end-reviewers,babolivier
https://hg.mozilla.org/comm-central/rev/6d55648b0cc0
Replace misleading nsIMsgOfflineImapOperation.flagOperation method with a method to explicitly set up kAddKeywords ops. r=thunderbird-back-end-reviewers,babolivier
https://hg.mozilla.org/comm-central/rev/5787e26b8431
Make nsIMsgOfflineImapOperation.operation read-only. r=thunderbird-back-end-reviewers,babolivier
https://hg.mozilla.org/comm-central/rev/f703fa543f35
Replace nsIMsgOfflineImapOperation string uses with AUTF8String. r=thunderbird-back-end-reviewers,babolivier

You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: