1
/***************************************************************************
2
smb4ksambaoptionsinfo - This is a container class that carries
3
various information of extra options for a specific host.
6
copyright : (C) 2006-2008 by Alexander Reinholdt
7
email : dustpuppy@users.berlios.de
8
***************************************************************************/
10
/***************************************************************************
11
* This program is free software; you can redistribute it and/or modify *
12
* it under the terms of the GNU General Public License as published by *
13
* the Free Software Foundation; either version 2 of the License, or *
14
* (at your option) any later version. *
16
* This program is distributed in the hope that it will be useful, but *
17
* WITHOUT ANY WARRANTY; without even the implied warranty of *
18
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
19
* General Public License for more details. *
21
* You should have received a copy of the GNU General Public License *
22
* along with this program; if not, write to the *
23
* Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, *
25
***************************************************************************/
27
#ifndef SMB4KSAMBAOPTIONSINFO_H
28
#define SMB4KSAMBAOPTIONSINFO_H
39
#include <kdemacros.h>
41
// forward declarations
47
* This class provides a container for all extra options that the user defined
48
* for a certain share.
50
* @author Alexander Reinholdt <dustpuppy@users.berlios.de>
53
class KDE_EXPORT Smb4KSambaOptionsInfo
63
* Enumeration for the protocol
65
enum Protocol{ Automatic,
72
* Enumeration for the write access
74
enum WriteAccess{ ReadWrite,
76
UndefinedWriteAccess };
79
* Enumeration for the use of Kerberos
81
enum Kerberos{ UseKerberos,
86
* Enumeration for use with remounting
88
enum Remount{ DoRemount,
93
* Constructor. It takes a Smb4KHost object and extracts all needed (and
94
* available) data. All missing information has to be set with the functions
95
* provided by this class.
97
* @param host The Smb4KHost object representing the host.
99
Smb4KSambaOptionsInfo( Smb4KHost *host );
102
* Constructor. It takes a Smb4KShare object and extracts all needed (and
103
* available) data. All missing information has to be set with the functions
104
* provided by this class.
106
* @param share The Smb4KShare object representing a share.
108
Smb4KSambaOptionsInfo( Smb4KShare *share );
111
* The copy constructor. It takes another Smb4KSambaOptionsInfo object @p info
112
* and copies its values.
114
* @param info A Smb4KShareOptionsInfo object
116
Smb4KSambaOptionsInfo( const Smb4KSambaOptionsInfo &info );
119
* The empty constructor. You have set all needed values with the functions
120
* provided by this class.
122
Smb4KSambaOptionsInfo();
127
~Smb4KSambaOptionsInfo();
130
* Sets the "should be remounted" flag.
132
* @param remount A value from the Remount enumeration that defines
133
* whether a remount should take place or not.
135
void setRemount( Smb4KSambaOptionsInfo::Remount remount );
138
* Returns TRUE if the share is to be remounted and FALSE otherwise.
140
* @returns a value from the Remount enumeration that determines whether the
141
* share should be remounted or not.
143
Smb4KSambaOptionsInfo::Remount remount() const { return m_remount; }
146
* This function sets the UNC of the item. If the item is a host, then you
147
* should only set the host name here. If the item is a share, the UNC should
148
* look like //[USER@]HOST/SHARE. Whether USER should be specified depends
149
* on your operating system (e.g. FreeBSD).
151
* @param unc The UNC of the network item
153
void setUNC( const QString &name );
156
* This function returns the UNC of the network item.
158
* @returns The UNC of the network item.
160
const QString &unc() const { return m_unc; }
163
* This function sets the port that should be used when querying this share.
165
* @param port The port number
167
void setPort( int port );
170
* This function returns the port that should be used when working with this
171
* share. Please note, that it will be returned as an integer. If no port has been
172
* defined, -1 will be returned.
174
* @returns the port number
176
int port() const { return m_port; }
179
* Set the protocol that is to be used with the net command.
181
* @param protocol One item from the Protocol enumeration defining
182
* the protocol that should be used.
184
void setProtocol( Smb4KSambaOptionsInfo::Protocol protocol );
187
* Returns the protocol that is to be used with the net command.
189
* @returns the protocol that is to be used with the net command.
191
Smb4KSambaOptionsInfo::Protocol protocol() const { return m_protocol; }
194
* Set the 'Use Kerberos' flag.
196
* @param kerberos One item from the Kerberos enueration defining
197
* if Kerberos should be used or not.
199
void setUseKerberos( Smb4KSambaOptionsInfo::Kerberos kerberos );
202
* This functions returns TRUE if the user wants to use Kerberos and
203
* otherwise it returns FALSE.
205
* @returns TRUE if Kerberos should be used and FALSE
208
Smb4KSambaOptionsInfo::Kerberos useKerberos() const { return m_kerberos; }
211
* With this function you can set the UID you want to use for this item.
212
* However, it makes only sense with shares.
216
void setUID( uid_t uid );
219
* This functions returns the UID defined for this item.
221
* Please note that the function will always return a UID (by default the
222
* user's UID). If you want to check if a UID set, use uidIsSet() function.
226
uid_t uid() const { return m_uid; }
229
* This function returns TRUE if the UID was set.
231
* @returns TRUE if the UID was set.
233
bool uidIsSet() const { return m_uid_set; }
236
* With this function you can set the GID you want to use for this item.
237
* However, it makes only sense with shares.
241
void setGID( gid_t gid );
244
* This functions returns the GID defined for this item.
246
* Please note that the function will always return a GID (by default the
247
* user's GID). If you want to check if a GID set, use uidIsSet() function.
251
gid_t gid() const { return m_gid; }
254
* This function returns TRUE if the GID was set.
256
* @returns TRUE if the GID was set.
258
bool gidIsSet() const { return m_uid_set; }
261
* This function returns the type of the network item for which the options
264
* @returns the type according to the Type enumeration.
270
* Set if the share is to be mounted read-write or read-only.
272
* Note: This function is not available und FreeBSD.
274
* @param write_access One of the values of the Type enumeration.
276
void setWriteAccess( Smb4KSambaOptionsInfo::WriteAccess write_access );
279
* This functions returns TRUE if the user wants to mount a share read-write
280
* otherwise it returns FALSE.
282
* Note: This function is not available und FreeBSD.
284
* @returns TRUE if read-write and FALSE otherwise.
286
Smb4KSambaOptionsInfo::WriteAccess writeAccess() const { return m_write_access; }
290
* Set if this item has custom options. Please note that @p has_options
291
* should even be set to FALSE if you have a share that is scheduled for
292
* remount, but all other options have default values.
294
* @param has_options Should be TRUE if this option has custom
295
* options and otherwise FALSE.
297
void setHasCustomOptions( bool has_options );
300
* This function returns TRUE if the item has custom options. Please note
301
* that it will even return FALSE if the item represents a share that is scheduled
302
* for remount, but all other options have default values. So, to check if this
303
* item has no custom options and is also not scheduled for remount, you need
304
* to do a check like this:
308
* if ( item->remount() && item->hasCustomOptions() )
315
* @returns TRUE if the item has custom options and FALSE otherwise.
317
bool hasCustomOptions() const { return m_has_custom_options; }
320
* Set the workgroup for this item.
322
* @param workgroup The workgroup for this item.
324
void setWorkgroup( const QString &workgroup );
327
* This function returns the workgroup of this item.
329
* @returns the workgroup of this item.
331
const QString &workgroup() const { return m_workgroup; }
334
* Set the IP address for this item. This function checks if the
335
* IP address complies either with IPv4 or IPv6 and only sets it
336
* if the check passes. In case the IP address is invalid, the
337
* internal IP address object is cleared.
339
* @param ip The IP address for this item.
341
void setIP( const QString &ip );
344
* This function returns the valid IP address of this item.
346
* @returns the IP address.
348
const QString &ip() const { return m_ip; }
351
* This function updates all values of an Smb4KSambaOptionsInfo object
352
* except the UNC, workgroup and IP address.
354
* @param info The object that is used for the update.
356
void update( Smb4KSambaOptionsInfo *info );
359
* This function returns all custom options in a sorted map. The UNC,
360
* workgroup and IP address must be retrieved separately if needed.
362
* Note that all entries that are not defined for a certain item have
365
* @returns all custom entries.
367
QMap<QString,QString> entries();
370
* Set the profile for which this custom options are to be used.
372
* @param name The name of the profile.
374
void setProfile( const QString &name );
377
* Return the name of the profile for which the options are to be
380
* @returns the name of the profile for which the options should be
383
const QString &profile() const { return m_profile; }
392
* Should be remounted?
403
* Mount read-write or read-only?
405
WriteAccess m_write_access;
414
* Use Kerberos or not
439
* Carries this item custom options?
441
bool m_has_custom_options;