summaryrefslogtreecommitdiff
path: root/mailnews/base/util/nsMsgTxn.h
blob: e925b60ea301d87d20bedaf4e8e30032893dddf5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/* 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 nsMsgTxn_h__
#define nsMsgTxn_h__

#include "mozilla/Attributes.h"
#include "nsITransaction.h"
#include "msgCore.h"
#include "nsCOMPtr.h"
#include "nsIMsgWindow.h"
#include "nsInterfaceHashtable.h"
#include "MailNewsTypes2.h"
#include "nsIVariant.h"
#include "nsIWritablePropertyBag.h"
#include "nsIWritablePropertyBag2.h"

#define NS_MESSAGETRANSACTION_IID \
{ /* da621b30-1efc-11d3-abe4-00805f8ac968 */ \
    0xda621b30, 0x1efc, 0x11d3, \
  { 0xab, 0xe4, 0x00, 0x80, 0x5f, 0x8a, 0xc9, 0x68 } }
/**
 * base class for all message undo/redo transactions.
 */

class NS_MSG_BASE nsMsgTxn : public nsITransaction, 
                             public nsIWritablePropertyBag,
                             public nsIWritablePropertyBag2
{
public:
    nsMsgTxn();

    nsresult Init();

    NS_IMETHOD DoTransaction(void) override;

    NS_IMETHOD UndoTransaction(void) override = 0;

    NS_IMETHOD RedoTransaction(void) override = 0;
    
    NS_IMETHOD GetIsTransient(bool *aIsTransient) override;

    NS_IMETHOD Merge(nsITransaction *aTransaction, bool *aDidMerge) override;

    nsresult GetMsgWindow(nsIMsgWindow **msgWindow);
    nsresult SetMsgWindow(nsIMsgWindow *msgWindow);
    nsresult SetTransactionType(uint32_t txnType);
 
    NS_DECL_THREADSAFE_ISUPPORTS
    NS_DECL_NSIPROPERTYBAG
    NS_DECL_NSIPROPERTYBAG2
    NS_DECL_NSIWRITABLEPROPERTYBAG
    NS_DECL_NSIWRITABLEPROPERTYBAG2

protected:
    virtual ~nsMsgTxn();

    // a hash table of string -> nsIVariant
    nsInterfaceHashtable<nsStringHashKey, nsIVariant> mPropertyHash;
    nsCOMPtr<nsIMsgWindow> m_msgWindow;
    uint32_t m_txnType;
    nsresult CheckForToggleDelete(nsIMsgFolder *aFolder, const nsMsgKey &aMsgKey, bool *aResult);
};

#endif