summaryrefslogtreecommitdiffstats
path: root/smb4k/core/smb4khomesshareshandler.h
blob: b343698ead7192dc02afd3a58e0a49ae85819052 (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
/***************************************************************************
    smb4khomesshareshandler  -  This class handles the homes shares.
                             -------------------
    begin                : Do Aug 10 2006
    copyright            : (C) 2006 by Alexander Reinholdt
    email                : dustpuppy@mail.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 SMB4KHOMESSHARESHANDLER_H
#define SMB4KHOMESSHARESHANDLER_H

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

// TQt includes
#include <tqobject.h>

// KDE includes
#include <kdialogbase.h>
#include <tdeconfig.h>


/**
 * This class belongs to the core of Smb4K and takes care of the
 * user names that are/were defined for a certain 'homes' share.
 *
 * @author Alexander Reinholdt <dustpuppy@mail.berlios.de>
 */

class Smb4KHomesSharesHandler : public TQObject
{
  Q_OBJECT
  

  public:
    /**
     * The constructor
     *
     * @param parent            The parent object of this class
     *
     * @param name              The name of this class
     */
    Smb4KHomesSharesHandler( TQObject *parent = 0, const char *name = 0 );

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

    /**
     * This function will open a dialog where the user has to define a
     * user name to access a 'homes' share. Besides returning this name,
     * this function will also store the name in the configuration file.
     *
     * @param host        The host where the homes share is located
     *
     * @param parent      The parent widget
     *
     * @param name        The name of this dialog
     *
     * @returns           A user name
     */
    const TQString specifyUser( const TQString &host, TQWidget *parent = 0, const char *name = 0 );

    /**
     * Read and return the user names that are defined for a homes share.
     *
     * @param host        The name of the host where the 'homes' share is located.
     *
     * @returns           the list of user names for this homes share.
     */
    const TQStringList &homesUsers( const TQString &host ) { return read_names( host ); }

  protected slots:
    /**
     * Is connected to the textChanged() signal of the combo box
     * in the "Specify User" dialog.
     *
     * @param text        The text in the combo box
     */
    void slotTextChanged( const TQString &text );

    /**
     * This slot is called if the User1 button, i.e. the "Clear" button
     * in the "Specify User" dialog has been clicked. It removes all
     * entries from the combo box.
     */
    void slotClearClicked();

  private:
    /**
     * Read the user names for a homes share.
     *
     * @param host              The host where the homes share is located.
     */
    const TQStringList &read_names( const TQString &host );

    /**
     * Write the user names for a certain homes share to the config
     * file.
     *
     * @param host              The host where the homes share is located
     *
     * @param names             The list of user names that are defined for
     *                          the homes share and should be written to the
     *                          config file.
     */
    void write_names( const TQString &host, const TQStringList &names );

    /**
     * This is the dialog that's shown the user when he/she has to
     * provide a user name.
     */
    KDialogBase *m_dlg;

    /**
     * This is a buffer for the list of names defined for a 'homes' share.
     */
    TQStringList m_names;
};

#endif