summaryrefslogtreecommitdiffstats
path: root/smb4k/configdlg/smb4kconfigdialog.h
blob: 55aab716bde6ac4162461b6402553cf611907a71 (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
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
/***************************************************************************
    smb4kconfigdialog  -  The configuration dialog of Smb4K
                             -------------------
    begin                : Sa Apr 14 2007
    copyright            : (C) 2007 by Alexander Reinholdt
    email                : dustpuppy@users.berlios.de
 ***************************************************************************/

/***************************************************************************
 *   This program is free software; you can redistribute it and/or modify  *
 *   it under the terms of the GNU General Public License as published by  *
 *   the Free Software Foundation; either version 2 of the License, or     *
 *   (at your option) any later version.                                   *
 *                                                                         *
 *   This program is distributed in the hope that it will be useful, but   *
 *   WITHOUT ANY WARRANTY; without even the implied warranty of            *
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU     *
 *   General Public License for more details.                              *
 *                                                                         *
 *   You should have received a copy of the GNU General Public License     *
 *   along with this program; if not, write to the                         *
 *   Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,   *
 *   MA  02110-1301 USA                                                    *
 ***************************************************************************/

#ifndef SMB4KCONFIGDIALOG_H
#define SMB4KCONFIGDIALOG_H

#ifdef HAVE_CONFIG_H
#include <config.h>
#endif

// KDE includes
#include <kconfigdialog.h>
#include <klibloader.h>
#include <kaboutdata.h>
#include <kinstance.h>

// forward declarations
class Smb4KSettings;

/**
 * This is the (new) configuration dialog of Smb4K.
 *
 * @author Alexander Reinholdt <dustpuppy@users.berlios.de>
 */

class Smb4TDEConfigDialog : public TDEConfigDialog
{
  Q_OBJECT
  

  public:
    /**
     * The constructor.
     *
     * @param settings      The Smb4KSettings object that needs to be passed
     *                      so that the settings can be managed.
     *
     * @param parent        The parent widget
     *
     * @param name          The name of this dialog
     */
    Smb4TDEConfigDialog( Smb4KSettings *settings, TQWidget *parent = 0, const char *name = 0 );

    /**
     * The destructor
     */
    ~Smb4TDEConfigDialog();

  protected:
    /**
     * Reimplemented from TQWidget to do last things before the
     * configuration dialog is shown.
     *
     * @param e             The show event object
     */
    void showEvent( TQShowEvent *e );

  protected slots:
    /**
     * Reimplemented from TDEConfigDialog. This slot does application
     * specific stuff first and then executes TDEConfigDialog::slotApply().
     */
    void slotApply();

    /**
     * Reimplemented from TDEConfigDialog. This slot does application
     * specific stuff first and then executes TDEConfigDialog::slotOk().
     */
    void slotOk();

    /**
     *Reimplemented from TDEConfigDialog. This slot does application
     * specific stuff first and then executes TDEConfigDialog::slotCancel().
     */
    void slotCancel();

    /**
     * The custom Samba settings changed. Decide if we have to
     * enable the 'Apply' button or not.
     */
    void slotCustomSambaSettingsChanged();

    /**
     * The 'Remove Entries' button in the 'Super User' page has been
     * clicked. Initialize the removal of Smb4K's configuration entries
     * from the configuration file of the currently chosen program.
     */
    void slotRemoveSuperUserEntries();

    /**
     * This slot is activated if the Smb4KFileIO::failed() signal is
     * received. It deselects all check boxes in the "Super User" page.
     */
    void slotReceivedFileIOFailed();

    /**
     * This slot is activated if the Smb4KFileIO::finished() signal is
     * received. It closes the dialog by invoking TDEConfigDialog::slotOk().
     */
    void slotReceivedFileIOFinished();

  private:
    /**
     * Load the custom Samba options
     */
    void loadCustomSambaOptions();

    /**
     * Save the custom Samba options
     */
    void saveCustomSambaOptions();

    /**
     * Load the authentication data
     */
    void loadAuthenticationData();

    /**
     * Save the authentication data
     */
    void saveAuthenticationData();

    /**
     * Write super user configuration entries to configuration file.
     *
     * @returns TRUE if something needs to be written.
     */
    bool writeSuperUserEntries();

    /**
     * Remove super user configuration entries from the configuration file.
     */
    void removeSuperUserEntries();

    /**
     * Checks that mandatorily needed input is provided for settings that
     * need it. This function will report all missing input to the user
     * via a message box.
     *
     * @returns TRUE if the check passed and FALSE if it failed.
     */
    bool checkSettings();
};


class TDEInstance;
class TDEAboutData;


class Smb4TDEConfigDialogFactory : KLibFactory
{
  Q_OBJECT
  

  public:
    /**
     * The constructor.
     */
    Smb4TDEConfigDialogFactory();

    /**
     * The destructor.
     */
    virtual ~Smb4TDEConfigDialogFactory();

    /**
     * The instance
     */
    static TDEInstance *instance();

  protected:
    TQObject *createObject( TQObject *parent = 0, const char *name = 0,
                           const char *classname = TQOBJECT_OBJECT_NAME_STRING,
                           const TQStringList &args = TQStringList() );

  private:
    /**
     * The factory's instance
     */
    static TDEInstance *m_instance;

    /**
     * The factory's TDEAboutData object
     */
    static TDEAboutData *m_about;
};

#endif