summaryrefslogtreecommitdiffstats
path: root/kshowmail/filterlog.h
blob: 2baaa5e880bd02de8a2aa59065063972dc5d9725 (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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
//
// C++ Interface: filterlog
//
// Description:
//
//
// Author: Ulrich Weigelt <ulrich.weigelt@gmx.de>, (C) 2007
//
// Copyright: See COPYING file that comes with this distribution
//
//
#ifndef FILTERLOG_H
#define FILTERLOG_H

//TQt headers
#include <tqvaluelist.h>
#include <tqdatetime.h>
#include <tqdom.h>
#include <tqfile.h>
#include <tqtextstream.h>

//KDE headers
#include <kdebug.h>
#include <tdemessagebox.h>
#include <tdelocale.h>
#include <kstandarddirs.h>
#include <tdeapplication.h>
#include <tdeconfig.h>

//KShowmail headers
#include "filterlogentry.h"
#include "constants.h"

/**
 * @brief This is the log of the filters.
 * It holds two lists of entry objects (class FilterLogEntry). One for the deleted mails and the other one for
 * the moved mails.
 *
 * @author Ulrich Weigelt <ulrich.weigelt@gmx.de>
 */

typedef TQValueList<FilterLogEntry> LogEntryList;


class FilterLog{


  public:

    /**
     * Default constructor
     */
    FilterLog();

    /**
     * Destructor
     */
    ~FilterLog();

    /**
     * Adds an entry about a deleted mail.
     * @param dateTime date and time on which the mail was sent
     * @param sender sender of the mail
     * @param account Account which has received the mail
     * @param subject Subject of the mail
     */
    void addDeletedMail( const TQDateTime& dateTime, const TQString& sender, const TQString& account, const TQString& subject );

    /**
     * Adds an entry about a moved mail.
     * @param dateTime date and time on which the mail was sent
     * @param sender sender of the mail
     * @param account Account which has received the mail
     * @param subject Subject of the mail
     * @param mailbox mailbox
     */
    void addMovedMail( const TQDateTime& dateTime, const TQString& sender, const TQString& account, const TQString& subject, const TQString& mailbox );

    /**
     * Prints the log state.
     */
    void print();

    /**
     * Clears the log of deleted mails.
     */
    void clearDeletedMailsLog();

    /**
     * Clears the log of moved mails.
     */
    void clearMovedMailsLog();

    /**
     * Saved the log of deleted mails as XML document.
     */
    void save();

    /**
     * Loads the log of deleted mails from the XML document and get settings.
     */
    void load();

    /**
     * Returns a copy of the list of deleted mails.
     * @return copy of the deleted mails list
     */
    LogEntryList getDeletedMails();

    /**
     * Retruns a copy of the list of moved mails.
     * @return copy of the moved mails list
     */
    LogEntryList getMovedMails();

    /**
     * Loads the settings
     */
    void loadSetup();

    /**
     * Returns the number of logged deleted mails.
     * @return number of logged deleted mails
     */
    int numberDeletedMails();

    /**
     * Returns the number of logged moved mails.
     * @return number of logged moved mails
     */
    int numberMovedMails();


  private:

    /**
     * Connector to the configuration file
     */
    TDEConfig* config;

    /**
     * List of entries about deleted mails.
     */
    LogEntryList listDeletedMails;

    /**
     * List of entries about moved mails.
     */
    LogEntryList listMovedMails;

    /**
     * TRUE - the log accepts orders to log deleted mails
     */
    bool logDeletedMails;

    /**
     * TRUE - the log accepts orders to log moved mails
     */
    bool logMovedMails;

    /**
     * exit - hold log of deleted mails until application exit
     * days - hold log some days
     */
    enum{ exit, days } deletedMailsStorageMode;

    /**
     * Time (days) a entry of a deleted mail will be stored.
     */
    unsigned int daysStoreDeletedMails;

  protected:

    /**
     * adds an entry.
     * The target list will be coose on the basis of the given filter action.
     */
    void addEntry( FilterAction_Type action, const TQDateTime& dateTime, const TQString& sender, const TQString& account, const TQString& subject, const TQString& mailbox = TQString::null );

};


#endif