summaryrefslogtreecommitdiffstats
path: root/kshowmail/kcmconfigs/configspamcheck.h
blob: 359fc9842b32273fc83da6c1e93179d6836125c6 (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
//
// C++ Interface: configspamcheck
//
// Description:
//
//
// Author: Ulrich Weigelt <ulrich.weigelt@gmx.de>, (C) 2008
//
// Copyright: See COPYING file that comes with this distribution
//
//
#ifndef CONFIGSPAMCHECK_H
#define CONFIGSPAMCHECK_H

//C-headers
#include <unistd.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>

//TQt headers
#include <tqlayout.h>
#include <tqlabel.h>
#include <tqgroupbox.h>
#include <tqtooltip.h>

//KDE headers
#include <tdecmodule.h>
#include <tdeconfig.h>
#include <kgenericfactory.h>
#include <tdeapplication.h>
#include <kpushbutton.h>
#include <kstdguiitem.h>
#include <kcombobox.h>
#include <klineedit.h>
#include <tdemessagebox.h>

//Kshowmail headers
#include "../constants.h"
#include "mailboxwizard.h"

//radio button IDs
#define ID_SPAM_ACTION_BUTTONS_DELETE     0
#define ID_SPAM_ACTION_BUTTONS_MARK       1
#define ID_SPAM_ACTION_BUTTONS_MOVE       2


/**
 * @brief Part of the setup dialog (KShowMailApp::SetupDialog) to configure the spam check.
 * @author Ulrich Weigelt <ulrich.weigelt@gmx.de>
 */
class ConfigSpamcheck : public TDECModule
{

Q_OBJECT


  public:
    /**
     * Generic constructor
     */
    ConfigSpamcheck( TQWidget* parent = 0, const char* name = 0, const TQStringList &args = TQStringList() );

    /**
     * Destructor
     */
    ~ConfigSpamcheck();

    /**
     * Overloaded method of TDECModule.
     * Sets the user interface elements to reflect the current settings stored in the
     * config file.
     */
    virtual void load();

    /**
     * Overloaded method of TDECModule.
     * Sets the user interface elements to default values.
     * This method is called when the user clicks the "Default" button.
     */
    virtual void defaults();

    /**
     * Overloaded method of TDECModule.
     * Stores the config information as shown in the user interface in the
     * config file.
     * Is called when the user clicks "Apply" or "Ok".
     */
    virtual void save();

  private:

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

    /**
     * Button to test for a running SpamAssassin
     */
    KPushButton* btnTest;

    /**
     * Combobox to select the action for spam.
     */
    KComboBox* cmbAction;

    /**
     * If selected, the spam mails will be moved to the mailbox which is written in this edit line.
     */
    KLineEdit* txtMailbox;

    /**
     * This button opens a wizard which will help to get the right mailbox
     */
    KPushButton* btnMailboxWizard;

    /**
     * Contains the widgets of action configuration.
     */
    TQGroupBox* gboxAction;

  private slots:

   /**
    * Connected with the configuration items.
    * Calls the slot changed() of TDECModule to notify the dialog about the change.
    */
    void slotChanged();

    /**
     * Connected with combobox cmbAction.
     * Enables or disables additional widgets for action configuration.
     * @param index position (index) of the selected action
     */
    void slotActionChanged( int index );

    /**
     * Connected with button btnMailboxWizard.
     * Opens a wizard to configure the mailbox
     */
    void slotOpenMailBoxWizard();

    /**
     * Connected with btnTest.
     * Tests whether SpamAssassin is running and shows a message box containing the result.
     * Enables or disables the action widgets.
     */
    void slotTestSpamAssassin();

  protected:

    /**
     * Looks for a running spamd daemon of SpamAssassin.
     * @return TRUE - SpamAssassin is running
     */
    bool isSpamAssassinRunning() const;

};

#endif