/* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ #ifndef COMM_MAILNEWS_PROTOCOLS_EWS_SRC_EWSCOPYMOVETRANSACTION_H_ #define COMM_MAILNEWS_PROTOCOLS_EWS_SRC_EWSCOPYMOVETRANSACTION_H_ #include "IEwsFolder.h" #include "nsMsgTxn.h" #include "nsIMsgHdr.h" #include "nsIMsgWindow.h" /** * A transaction representing an intra-server EWS copy or move operation. */ class EwsCopyMoveTransaction : public nsMsgTxn { public: /** * Return a transaction for a copy operation. * * The copy operation copied items from `originalSourceFolder` to * `originalDestinationFolder`. The `window` is the containing window for the * operation that also manages the undo stack. The `originalHeaders` parameter * represents the headers that were used as the source headers for the * original operation. The `newHeaders` parameter should contain the headers * that resulted from the original operation (i.e. The resulting headers from * the original copy or move operation). */ static RefPtr ForCopy( nsCOMPtr originalSourceFolder, nsCOMPtr originalDestinationFolder, nsCOMPtr window, nsTArray> originalHeaders, nsTArray> newHeaders); /** * Return a transaction for a move operation. * * @see `EwsCopyMoveTransaction::ForCopy` for an explanation of the * parameters. */ static RefPtr ForMove( nsCOMPtr originalSourceFolder, nsCOMPtr originalDestinationFolder, nsCOMPtr window, nsTArray> newHeaders); NS_IMETHOD UndoTransaction() override; NS_IMETHOD RedoTransaction() override; /** * Replace the collection of headers so that the next undo/redo operates on * the given `headers`. */ void UpdateHeaderSet(const nsTArray>& headers); protected: virtual ~EwsCopyMoveTransaction(); private: /** * Construct an Undo/Redo transaction for a copy or move operation. * * @see `EwsCopyMoveTransaction::ForCopy` for an explanation of the * parameters. */ EwsCopyMoveTransaction(nsCOMPtr originalSourceFolder, nsCOMPtr originalDestinationFolder, nsCOMPtr window, bool isMove, nsTArray>&& originalHeaders, nsTArray>&& newHeaders); /** * Perform the operation, moving the current set of headers from `fromFolder` * and to `toFolder`. */ nsresult PerformOperation(IEwsFolder* fromFolder, IEwsFolder* toFolder); const nsCOMPtr mOriginalSourceFolder; const nsCOMPtr mOriginalDestinationFolder; const nsCOMPtr mWindow; const bool mIsMove; const nsTArray> mOriginalHeaderSet; nsTArray> mCurrentHeaderSet; }; #endif // COMM_MAILNEWS_PROTOCOLS_EWS_SRC_EWSCOPYMOVETRANSACTION_H_