summaryrefslogtreecommitdiffstats
path: root/smb4k/core/smb4ksambaoptionsinfo.h
blob: 80e141f6aedc7d53323d644552c38b594c306ea9 (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
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
/***************************************************************************
    smb4ksambaoptionsinfo  -  This is a container class that carries
    various information of extra options for a specific host.
                             -------------------
    begin                : Mi Okt 18 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 SMB4KSAMBAOPTIONSINFO_H
#define SMB4KSAMBAOPTIONSINFO_H

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

// TQt includes
#include <tqstring.h>

#include <kdemacros.h>

// forward declarations
class Smb4KShare;


/**
 * This class provides a container for all extra options that the user defined
 * for a certain share.
 *
 * @author  Alexander Reinholdt <dustpuppy@mail.berlios.de>
 */

class KDE_EXPORT Smb4KSambaOptionsInfo
{
  public:
    /**
     * Constructor. It takes the name of the network item in the form
     * HOST or //HOST/SHARE as only argument. If you use this constructor, you
     * need to use the set* functions to add information.
     *
     * @param name              The network item's name.
     */
    Smb4KSambaOptionsInfo( const TQString &name );

    /**
     * Constructor. It takes a Smb4KShare object and extracts the name and the
     * filesystem from it. All other information has to be set with the set*
     * functions.
     *
     * @param share             A Smb4KShare object representing a share.
     */
    Smb4KSambaOptionsInfo( Smb4KShare *share );

    /**
     * The copy constructor.
     *
     * @param info              A Smb4KShareOptionsInfo object
     */
    Smb4KSambaOptionsInfo( const Smb4KSambaOptionsInfo &info );

    /**
     * The destructor.
     */
    ~Smb4KSambaOptionsInfo();

    /**
     * Sets the "should be remounted" flag.
     *
     * @param rm                TRUE if the share is to be remounted and
     *                          FALSE otherwise.
     */
    void setRemount( bool rm );

    /**
     * Returns TRUE if the share is to be remounted and FALSE otherwise.
     *
     * @returns                 TRUE if the share is to be remounted and FALSE otherwise
     */
    bool remount() const { return m_remount; }

    /**
     * This function sets the item name.
     *
     * @param name              The name of the network item
     */
    void setItemName( const TQString &name );

    /**
     * This function returns the name of the network item, i.e. the server or
     * share.
     *
     * @returns                 the name of the network item.
     */
    const TQString &itemName() const { return m_name; }

    /**
     * This function sets the port that should be used when querying this share.
     *
     * @param port              The port number
     */
    void setPort( int port );

    /**
     * This function returns the port that should be used when working with this
     * share. Please note, that it will be returned as an integer. If no port has been
     * defined, -1 will be returned.
     *
     * @returns                 the port number
     */
    int port() const { return m_port; }

    /**
     * This function sets the protocol to use with the net command. If @p protocol
     * is equal to "auto", the protocol will automatically be set to "" internally,
     * so that Smb4KSambaOptionsInfo::protocol() returns an empty string.
     *
     * @param protocol          the protocol
     */
    void setProtocol( const TQString &protocol );

    /**
     * This function returns the protocol to use with the net command.
     *
     * @retuns                  the protocol
     */
    const TQString &protocol() const { return m_protocol; }

    /**
     * Set the 'Use Kerberos' flag.
     *
     * @param krb               TRUE if the user wants to use Kerberos
     *                          and FALSE otherwise.
     */
    void setKerberos( bool krb );

    /**
     * This functions returns TRUE if the user wants to use Kerberos and
     * otherwise it returns FALSE.
     *
     * @returns                 TRUE if Kerberos should be used and FALSE
     *                          otherwise.
     */
    bool kerberos() const { return m_kerberos; }

    /**
     * With this function you can set the UID you want to use for this item.
     * However, it makes only sense with shares.
     *
     * @param uid               The UID
     */
    void setUID( const TQString &uid );

    /**
     * This functions returns the UID defined for this item.
     *
     * @returns                 the UID.
     */
    const TQString &uid() const { return m_uid; }

    /**
     * With this function you can set the GID you want to use for this item.
     * However, it makes only sense with shares.
     *
     * @param gid               The GID
     */
    void setGID( const TQString &gid );

    /**
     * This functions returns the GID defined for this item.
     *
     * @returns                 the GID.
     */
    const TQString &gid() const { return m_gid; }

    /**
     * This function returns the type of the network item for which the options
     * have been defined.
     *
     * @returns the type according to the Type enumeration.
     */
    int type();

    /**
     * The Type enumeration.
     */
    enum Type { Share, Host };

#ifndef __FreeBSD__
    /**
     * This function sets the file system that is to be used when mounting the share.
     *
     * Note: This function is not available und FreeBSD.
     *
     * @param fs                the file system name
     */
    void setFilesystem( const TQString &fs );

    /**
     * This function returns the file system that is to be used.
     *
     * Note: This function is not available und FreeBSD.
     *
     * @returns                 the file system name
     */
    const TQString &filesystem() const { return m_filesystem; }

    /**
     * Set if the share is to be mounted read-write or read-only.
     *
     * Note: This function is not available und FreeBSD.
     *
     * @param rw                TRUE if read-write and FALSE otherwise.
     */
    void setWriteAccess( bool rw );

    /**
     * This functions returns TRUE if the user wants to mount a share read-write
     * otherwise it returns FALSE.
     *
     * Note: This function is not available und FreeBSD.
     *
     * @returns                 TRUE if read-write and FALSE otherwise.
     */
    bool writeAccess() const { return m_write_access; }
#endif

  private:
    /**
     * The share name.
     */
    TQString m_name;

    /**
     * Should be remounted?
     */
    bool m_remount;

    /**
     * The port number
     */
    int m_port;

#ifndef __FreeBSD__
    /**
     * The file system
     */
    TQString m_filesystem;

    /**
     * Mount read-write or read-only?
     */
    bool m_write_access;
#endif

    /**
     * The protocol
     */
    TQString m_protocol;

    /**
     * Use Kerberos or not
     */
    bool m_kerberos;

    /**
     * The UID
     */
    TQString m_uid;

    /**
     * The GID
     */
    TQString m_gid;
};

#endif